Skip to content

Latest commit

 

History

History
 
 

solidity

Solidity

Configure Development Environment

NPM dependencies

The project uses GitHub Package Registry for keep-network dependencies. It requires `npm login --registry=https://npm.pkg.github.com to be executed to authenticate with GitHub account in order to access private packages. You can login with GitHub access token by providing your username and instead of password use the token.

Install the project dependencies:

npm install

keep-core contracts

This project depends on contracts migrated by keep-core project and expects its migration artifacts to be provided in build/contracts directory. The contracts can be fetched from Google Cloud Bucket (for CI) or copied over from local source (for development) after running migrations in keep-core project.

To fetch required contracts addresses from keep-core project execute command:

KEEP_CORE_ARTIFACTS=~/go/src/github.com/keep-network/keep-core/contracts/solidity/build/contracts \
   ./scripts/lcl-provision-external-contracts.sh

Remember to update KEEP_CORE_ARTIFACTS with path where migrations artifacts are stored on your machine.

Staking and bonding

Keeps creation depends on operator's KEEP token staking and available bonding value. To initialize the operator:

  1. Initialize token staking in keep-core:

    # Run from `keep-core/contracts/solidity` directory
    truffle exec ./scripts/demo.js --network local
  2. Initialize operator for Bonded ECDSA keep factory.

    # Run from `keep-ecdsa/solidity` directory
    truffle exec scripts/lcl-initialize.js`

Usage

Currently contracts can be installed as npm dependency, in the future we may consider supporting EthPM.

Truffle

Truffle is a development framework for Ethereum.

To install it run:

npm install -g truffle

Configuration file truffle-config.js requires to contain a blockchain connection details. See next section for information on running a test blockchain.

Ganache

To start testing and developing you need to have a test blockchain set up. You can use Ganache for this.

To install Ganache on MacOS run:

brew cask install ganache

Open Ganache app and configure a server to be exposed with hostname 127.0.0.1 on port 8545.

Deploy contracts

To deploy contracts ensure Ganache is running and Truffle configured. If all is set run:

truffle migrate --reset

Command will output details of deployed contracts, find contract address value for each contract and copy-paste it to config.toml file.

Testing

Unit

Unit tests use Truffle's test framework, and redeploy contracts for a clean environment every test. An example:

truffle test test/BondedECDSAKeepTest.js

Scenarios

Tests in test/integration/ are for testing different scenarios in the Go client. They do not redeploy contracts, instead using the already deployed instances from truffle migrate.

truffle exec test/integration/keep_signing.js