Giter VIP home page Giter VIP logo

eth-contracts's Introduction

Current effective version

Current version being used in testnet is ./contracts/core

Generate abi files instruction

Download go-ethereum, choose the preferred version and build the executable abigen file.

./abigen --sol ./contracts/core/cross_chain_manager/data/EthCrossChainData.sol --pkg eccd_abi > ./go_abi/eccd_abi/eccd_abi.go

./abigen --sol ./contracts/core/cross_chain_manager/logic/EthCrossChainManager.sol --pkg eccm_abi > ./go_abi/eccm_abi/eccm_abi.go

./abigen --sol ./contracts/core/cross_chain_manager/upgrade/EthCrossChainManagerProxy.sol --pkg eccmp_abi > ./go_abi/eccmp_abi/eccmp_abi.go

./abigen --sol ./contracts/core/lock_proxy/LockProxy.sol --pkg lock_proxy_abi > ./go_abi/lock_proxy_abi/lock_proxy.go

./abigen --sol ./contracts/core/assets/btc/BTCX.sol --pkg btcx_abi > ./go_abi/btcx_abi/btcx_abi.go

./abigen --sol ./contracts/core/assets/ont/xONT.sol --pkg ontx_abi > ./go_abi/ontx_abi/ontx_abi.go

./abigen --sol ./contracts/core/assets/ong/ONGX.sol --pkg ongx_abi > ./go_abi/ongx_abi/ongx_abi.go

./abigen --sol ./contracts/core/assets/oep4_template/OEP4Template.sol --pkg oep4_abi > ./go_abi/oep4_abi/oep4_abi.go

./abigen --sol ./contracts/core/assets/erc20_template/ERC20Template.sol --pkg erc20_abi > ./go_abi/erc20_abi/erc20_abi.go


Truffle test instruction

install pkg

npm install --save-dev @openzeppelin/test-helpers

truffle documentation

web3.js api reference

compile

truffle compile

deploy

truffle migrate

test

Before run a full round of test or test/EthCrossChainManagerv3.0Test.js file, make sure you commit the following code within verifyAndExecuteTx() method in both EthCrossChainManager.sol and new EthCrossChainManager.sol.

//TODO: check this part to make sure we commit the next line when doing local net UT test
require(_executeCrossChainTx(toContract, toMerkleValue.makeTxParam.method, toMerkleValue.makeTxParam.args, toMerkleValue.makeTxParam.fromContract, toMerkleValue.fromChainID), "Execute CrossChain Tx failed!");

To run a full test under test folder, use

truffle test

To run a specific test js file under test folder, use

truffle test ./test/ZeroCopySinkTest.js

In truffle console / truffle development mode

Get contract instance in truffle console:

  1. let instance = await MetaCoin.deployed()
  2. Or suppose contract address ๏ผš 0x133739AB03b9be2b885cC11e3B9292FDFf45440E, we can use let instance = await Contract.at("0x133739AB03b9be2b885cC11e3B9292FDFf45440E") to obtain the instance.

Call contract function (pre-invoke/ pre-execute)

instance.name() / await instance.name()

(await instance.totalSupply()).toNumber()

Or we can also use

await instance..name.call()

send Transaction: (invoke / execute)

let result = await instance.transfer(accounts[1], 100)

the returned structure is the following:

result = {
    "tx": .., 
    "receipt": ..,
    "logs": []
}

await instance.approve(accounts[2], 100)

(await instance.allowance(accounts[0], accounts[2])).toNumber()

let result1 = await instance.transferFrom(accounts[0], accounts[2], 1, {from:accounts[2]}) ({from: ***} to indicate the msg.sender of this transaction)

about ether

Note: in truffle console, accounts by default means eth.web3.accounts

query balance : web3.eth.getBalance(accounts[0])

send ether: web3.eth.sendTransaction({from: accounts[0], to: accounts[1], value: web3.utils.toWei('1', "ether")})

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.