Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

🔧 🚧 Testing Provable's Random Example.

 

This repo is to demonstrate how you would set up a Provable smart-contract development environment using Truffle to do most of the heavy lifting for you. Head on over to the ./test folder to examine the javascript files that thoroughly test the smart-contract, which latter you will find in ./contracts.

📃 Instructions

The random datasource is currently available on the Ethereum mainnet and on some Ethereum public testnets only (Rinkeby, Kovan, and Ropsten Revival); and it is not integrated yet with private blockchains/testrpc/browser-solidity-vmmode, so you will need to get a mnemonic passphrase and an infura key to make the example work.

1) Go on the Infura website to get an Infura key: infura.io. The key is a 32 HEX characters string

2) Get a mnemonic passphrase, an easy way is to get a Metamask one: metamask.io

3) Fire up your favourite console & clone this repo somewhere:

❍ git clone https://github.com/provable-things/ethereum-examples.git

4) Enter this directory & install dependencies:

❍ cd ethereum-examples/solidity/truffle-examples/random-datasource && npm install

5) In ethereum-examples/solidity/truffle-examples/random-datasource, create a new file apikeys.js or .env and add the mnemonic passphrase and the Infura key to it, such as:

// apikeys.js example

module.exports = {
  mnemonic: 'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12',
  infuraKey: '0123456789abcdef0123456789abcdef'
}

or

// .env example

mnemonic = 'word1 word2 word3 word4 word5 word6 word7 word8 word9 word10 word11 word12'
infuraKey = '0123456789abcdef0123456789abcdef'

6) Compile with Truffle:

❍ npx truffle compile

7) Test the contract with Truffle leveraging a testnet, such as Rinkeby:

❍ npx truffle test --network rinkeby

 

📷 Passing Tests:

  Contract: Random Example Tests
    ✓ Should log a new Provable query (2421ms)
    ✓ Callback should have logged a new uint random number result event (54739)
    ✓ Should revert on second query attempt due to lack of funds (15290ms)

  3 passing (1m)

 

✒️ Notes:

Note that your own Infura key and the Metamask passphrase must be kept secure. The ones provided here are simply placeholders.

If you have any issues, head on over to our Gitter channel to get timely support!

Happy developing!

You can’t perform that action at this time.