Oasis Contract Kit
The Oasis Contract Kit can be used to build, test, and deploy smart contracts written in Solidity or Rust. The Contract Kit is a Docker image with a pre-configured set of tools meant to improve your productivity as a developer. We recommend using this development environment. While contract development remains a rapidly evolving ecosystem, there is a tough balance to maintain between taking advantage of the features provided by recent changes, and the instability and incompatibilities introduced by them. This Docker environment allows us to select recent and compatible versions of relevant tools.
To use the Contract Kit, you'll need Docker. If you don't already have Docker installed, you can find instructions for your preferred operating system here:
Getting Contract Kit
The latest version of the toolkit can be downloaded by running
docker pull oasislabs/contract-kit
Starting Contract Kit
The development environment can be started by running the
contract-kit Docker image and developing within the container. For many developers, you may not want to keep your development sources within a Docker environment, since it can add complexity to version control and working with a local editor. For these reasons, we recommend using a volume mount to expose a local directory with your source code into the container.
To launch Contract Kit, run
docker run -ti --rm -v "$PWD":/project oasislabs/contract-kit bash
This runs a Docker container using the specified
contract-kit image and opens a bash shell within the running container. It mounts the current directory at
/project in the container.
It is often useful to forward ports, for example, if you want to run a web server for your DApp from within docker. To do so, simply add the following arguments to the above command
-p 3000:3000 would ensure all requests to
localhost:3000 are forwarded to the docker image's own port 3000.
It's also useful to have multiple shells open for development. To find the name and identifier of the running container, run
Using either the container name or container identifier, you can launch additional shells by running
docker exec -ti <container-name or container-id> bash
Exiting the initial Docker shell will terminate the container instance, and close subsequently opened shells.
Launching a Local Blockchain
The Docker image contains a version of Parity that provides useful debugging information such as gas profiling and log messages. You can use this tool to test your smart contracts locally before deploying them to Oasis Devnet.
The local blockchain currently does not have support for Oasis-specific contract settings, i.e., confidential smart contracts and storage expiry. Please use the Devnet when testing smart contracts using these features as in the secret ballot tutorial.
To launch the local chain from within the Docker container:
parity --chain oasis --jsonrpc-interface=all
While this command is running, you can issue web3 calls to
http://127.0.0.1:8545 within the Docker container.
Accounts on Local Blockchain
When launched, Parity prints a list of 10 accounts available for testing on the local blockchain, each with 100 DEV initial balance.
The accounts are derived from the following mnemonic:
range drive remove bleak mule satisfy mandate east lion minimum unfold ready
If you are developing with Truffle, follow these instructions
to ensure Truffle uses these accounts when deploying to the local blockchain
truffle migrate --network development.
As part of the Contract Kit, we have assembled the following tools:
- truffle - development and testing framework
- parity - for running a local testing chain via
parity --chain oasis
- rustc/cargo - to compile Rust contracts to a WASM target
Check out our video tutorial for step-by-step instructions on how to set up and use Contract Kit.