Skip to content
No description, website, or topics provided.
JavaScript CSS HTML
Branch: staging
Clone or download
Latest commit 05310a5 Oct 31, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Update the project name in github instructions Feb 14, 2018
.storybook Search all src files for stories, should keep stories close to the co… Mar 7, 2019
docker fix: minor - remove trailing commas in config section Oct 31, 2019
ganache Fix path of big number (#25) Aug 2, 2019
truffle integrate tokens with contracts (#23) Aug 2, 2019
.gitignore fix path of bignumber (#24) Jul 31, 2019
README.md
package.json Removed main field from package.json Jul 17, 2019

README.md

Ganache with RSK

Note for For MAC OSX Developers

  1. Ensure you are running xcode directly and not the command-line instance. Run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Clone the RSK truffle-integration

  1. git clone https://github.com/rootstock/truffle-integration
  2. cd truffle-integration/

RSKJ Docker

Install Docker (Windows/Mac OS | Ubuntu) and make sure you are able to run docker ps at your terminal

Open a terminal

cd /truffle-integration/docker # Where you've cloned the repo 
docker build --tag regtest -f Dockerfile.RegTest .

This comamnd will build download Rskj node and build the image. It takes about 10 mins for the first time downloading.

Once built, you can run an image container

docker run -d --name regtest-node-01 -p 4444:4444 -p 4445:4445 -p 30305:30305 regtest

This command will start an RSKJ node with port 4444, 4445 and 30305 open

To shut down or remove the active container

docker container list || docker kill <container id> || docker rm <container id>

Linux users

Run docker commands with sudo

RSKJ Docker Contribute

  1. Sign in at https://hub.docker.com/ (or register a new account)

Ganache

  1. Navigate to /ganache
  2. npm install. This will install required dependencies for ganache
  3. npm start will start Ganache in development environment

Truffle

  1. Navigate to /truffle
  2. npm install
  3. truffle migrate --reset --network regtest to deploy Coin smart contract. run it twice to avoid truff issue #2224
  4. Once deployed, run truffle console --network regtest. The Coin variable is already defined in the console.
  5. Mint Coin Coin.deployed().then((instance=>instance.mint("0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", 100)))
  6. Then, send Coin by Coin.deployed().then((instance=>instance.send('0x7986b3DF570230288501EEa3D890bd66948C9B79',50)))
  7. For the EIP20, check balance EIP20.deployed().then((instance=>instance.balanceOf("0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826")))
  8. Transfer from the minter account to another account EIP20.deployed().then((instance=>instance.transfer("0x7986b3DF570230288501EEa3D890bd66948C9B79", 1)))
  9. Approve another account for certain allowance to spend EIP20.deployed().then((instance=>instance.approve("0x7986b3DF570230288501EEa3D890bd66948C9B79", 10)))
  10. Check the allowance is indeed existing EIP20.deployed().then((instance=>instance.allowance("0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826","0x7986b3DF570230288501EEa3D890bd66948C9B79")))
  11. Switch to the other account in truffle ,truffle console --network regtestAccountTwo
  12. Then execute this transfer EIP20.deployed().then((instance=>instance.transferFrom("0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", "0x7986b3DF570230288501EEa3D890bd66948C9B79",3)))

FAQ:

1. How to link Truffle projects to Ganache?

  1. To link a project, enter the settings by clicking the gear icon in the upper right. gear-icon
  2. You should be seeing the WORKSPACE settings pane; if not, you can get there by clicking the WORKSPACE tab in the top left. workspace
  3. From here, there is a section labeled TRUFFLE PROJECTS. Beneath this box, click the button ADD PROJECT. A file selection popup will appear. Navigate to the folder of your Truffle project, and select the truffle-config.js or truffle.js configuration file. The file you pick must be either named truffle-config.js or truffle.js for Ganache to correctly load it. add-project folder-selection
  4. After selecting the file, you'll see it listed in the TRUFFLE PROJECTS section. truffle-project-list
  5. After you're finished with adding projects you can click the SAVE AND RESTART (SAVE WORKSPACE if this is a new workspace) button in the top right. save-truffle-project (insert screenshots that are similar to the ones on this page) https://www.trufflesuite.com/docs/ganache/truffle-projects/linking-a-truffle-project

2. Why are events not shown in Ganache?

Ganache'll try to decode the events that are defined in the contracts within the corresponding Truffle project. Check and make sure you've them ready.

  1. Make sure you have linked the corresponding Truffle project truffle-project-list
  2. Make sure the contracts are already deployed. It should have a badge named deployed right next to it. (See screenshot below) make-sure-deployed
  3. Make sure the event is emitted in the contract's construction method. The reason is Ganache can only monitor events that has been fired on chain before. make-sure-events-emitted
  4. Make sure the contract's json file has the events field. The contract's json file can be found in path /build/.json. Open the json file and search for networks. You should see "33" under the "networks" key and also "events" under the "33". (See screenshot below). If the events field is empty, run migrate --reset to re-deploy the contract. This is due to an issue within the truffle development tool https://github.com/trufflesuite/truffle/issues/2224

make-sure-events-exist

You can’t perform that action at this time.