Skip to content

DONTEAM/gnosis.js

 
 

Repository files navigation

Gnosis.js Library

Logo

Build Status

Slack Status

Really quick start

  1. Get TestRPC
  2. Run this:
    testrpc -d -i 437894314312
    
  3. 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
    
  4. Download gnosis.js and put it in an HTML file:
    <script src=gnosis.js></script>
    
  5. Follow some tutorials:

Installation

Run npm install to install dependencies.

Needs a Web3 provider to work. For testing, try TestRPC.

Development

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.

Building

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.

Running the dev server

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.

Running the tests

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.

Documentation

API documentation and tutorials can be found hosted online at https://gnosis.github.io/gnosis.js/

Running the docs

Run npm run doc to build and open a local build of the documentation in your browser.

Web3 options

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.

Gas estimations

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' }))

About

Gnosis JavaScript Library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • JavaScript 100.0%