Giter Site home page Giter Site logo

truffle-integration's Introduction

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 trufflesuite/truffle#2224

make-sure-events-exist

truffle-integration's People

Contributors

adrianmcli avatar alebanzas avatar benjamincburns avatar bguiz avatar bmmpxf avatar cameronrll avatar chrisli30 avatar davidmurdoch avatar edevil avatar fedejinich avatar honestbonsai avatar jaycenhorton avatar johnmcdowall avatar kylezhai avatar logical-steps avatar lookrain avatar michaelbaudino avatar mikeseese avatar netergart avatar nunohora avatar onlyonejmjq avatar tcoulter avatar willli666 avatar wuya666 avatar xitter avatar xuhuang37 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

truffle-integration's Issues

Issue with Ganache installation #Step 2 in Getting Started

When running npm install in the Ganache folder (step 2 of the Getting Started tutorial) Im getting some compilation errors in some libraries.

Expected Behavior

Package installation should run smoothly like it happened with the truffle and docker steps.

Current Behavior

Getting some compilation errors and the process ends unexpectedly. View attached log #1.

Possible Solution

I've done some research and tried some options. Looks like there are similar errors reported and has to do with compatibility issues of some of the libraries with Node. Issues appear to be on the electron and fs-xattr libraries. Tried uninstalling and reinstalling but didnt fix the issue for those libraries, still fail in compilation.

Steps to Reproduce (for bugs)

  1. Clone repo
  2. Access ganache folder
  3. Run npm install

Context

I am not being able to run Ganache by executing npm start in the Ganache folder. Im getting errors. View attached log #2

Your Environment

  • Environment name and version : Node version 13.5.0 NPM version: 6.13.4
  • Operating System and version: MAC OS Catalina 10.15.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.