- Get TestRPC
- Run this:
testrpc -d -i 437894314312
- Clone Gnosis contracts, cd in there, and migrate the contracts onto the TestRPC instance with:
cd path/to/gnosis-contracts npm install npm run migrate
- Download
gnosis.js
and put it in an HTML file:<script src=gnosis.js></script>
- Follow some tutorials:
Run npm install
to install dependencies.
Needs a Web3 provider to work. For testing, try TestRPC.
Before you begin, you will want to have the contracts deployed on the chain you plan to use. You can deploy contracts through the RPC interface on localhost:8545 with
npm run migrate
The build process using Truffle will insert the chain locations in a networks
key on the contract build artifacts.
You can run npm run nodebuild
to build the library for Node.js use.
You can also run npm run webbuild
to build the library targeting the web. Note that this will compile in all network information present in the build artifacts, including temporary network information generated by TestRPC during migrations. You may use npm run netreset
beforehand to remove unofficial network info and reset to official deployed locations if desired.
Run npm run dev
to run the dev server and serve the examples. The library source will be continuously recompiled. Examples will be available on http://localhost:8080. Don't forget to refresh the page after you change the source.
Run npm test
to run test suite. This should run without the need of an RPC provider running on localhost:8545. If you already have such a provider running and wish to run the test suite without automatically spinning up TestRPC and causing a chain migration, use npm run test-manual
.
You may also provide mocha options through the MOCHA_OPTS
environment variable, e.g. MOCHA_OPTS='-g estimate' npm test
.
API documentation and tutorials can be found hosted online at https://gnosis.github.io/gnosis.js/
Run npm run doc
to build and open a local build of the documentation in your browser.
The methods on the API can be provided with from
, to
, value
, gas
, and gasPrice
options which get passed down to the web3.js
layer.
Many of the methods on the gnosis API also have an asynchronous estimateGas
property which you can use, while allowing you to specify the gas estimation source. For example:
// using the estimateGas RPC
await gnosis.createCentralizedOracle.estimateGas(ipfsHash, { using: 'rpc' }))
// using stats derived from gnosis-contracts
await gnosis.createCentralizedOracle.estimateGas({ using: 'stats' }))