移植到墨客平台

MOAC developed its VNODE client based on the Ethereum project. It also implements a *javascript runtime environment* (JSRE) that can be used in either interactive (console) or non-interactive (script) mode. It supports Dapp development through its own `chain3 <>`__ JavaScript API, just like web3.js on Ethereum.

If you want to develop Dapp on MOAC, you should use Solidity. MOAC supports the deployment of smart contracts through Remix, wallet.moac.io and For a Dapp that wants to move to MOAC from Ethereum, please follow these steps:

  1. Deploy the smart contract:

    You can check the two examples in our wiki page:

    ERC20

    ERC721

  2. Interact with the smart contract:

    • chain3, developed based on web3.js 0.2.x, is the JavaScript library supported by MOAC.
    • web3.js, only the functions listed in chain3 are workable, such as web3, eth, admin.

Example

Web3.js:

var Web3 = require('../index.js');
var web3 = new Web3();

web3.setProvider(new web3.providers.HttpProvider('http://localhost:8545'));

var coinbase = web3.eth.coinbase;
console.log(coinbase);

var balance = web3.eth.getBalance(coinbase);
console.log(balance.toString(10));

Chain3:

var Chain3 = require('../index.js');
var chain3 = new Chain3();

chain3.setProvider(new chain3.providers.HttpProvider('http://localhost:8545'));

var coinbase = chain3.mc.accounts[0];
console.log(coinbase);

var balance = web3.eth.getBalance(coinbase);
console.log(balance.toString(10));