移植到MOAC平台
优质
小牛编辑
125浏览
2023-12-01
MOAC的基础链节点是基于 以太坊 项目开发的,具有类似的借口环境。 在MOAC基础链上开发分布式应用(DAPP)
1. 在MOAC基础链上部署Solidity编写的智能合约,确保有能够接入MOAC链的节点, 可以使用主网公共节点(http://gateway.moac.io/mainnet)或者测试网公共节点(http://gateway.moac.io/testnet)。
- Remix, a browser compiler for Solidity.
- wallet.moac.io, a browser Dapp connect with local nodes to deploy contracts.
- Node.Js Solidity compiler, a JavaScript bindings for the Solidity compiler.
在MOAC的WIKI上面有两个基于基础链的示例:
- 调用基础链的智能合约可以通过chain3的相应工具来进行:
- chain3, developed based on web3.js 0.2.x, is the JavaScript library supported by MOAC.
3. 在MOAC应用链上部署Solidity编写的智能合约,需要获得MOAC应用链的地址,或者通过测试应用链的 html/dapps/RestfulAPI.html 和 html/dapps/SDK.html 进行, 也可以通过以下工具进行部署:
- wallet.moac.io, a browser Dapp connect with local nodes to deploy contracts.
- Node.Js Solidity compiler, a JavaScript bindings for the Solidity compiler.
可以参考:
示例
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 = chain3.mc.getBalance(coinbase); console.log(balance.toString(10));
智能合约Solidity
- Solidity: a smart contract programming language sharing similarities with Javascript and C++
- Solidity Glossary
- Solidity Features
- Solidity Collections
- Solidity Cheat-sheet