您好,欢迎来到化拓教育网。
搜索
您的当前位置:首页0x05 智能合约开发流程详解

0x05 智能合约开发流程详解

来源:化拓教育网

编写sol

contracts 文件夹下放置*.sol 文件
引入其他文件,注意大小写

编译contracts下的sol

vim 2_deploy_contracts.js 

example:

var Ownable = artifacts.require("./Ownable.sol");
var SafeMath = artifacts.require("./SafeMath.sol");
var Payroll = artifacts.require("./Payroll.sol");

module.exports = function(deployer) {
  deployer.deploy(Ownable);
  deployer.deploy(SafeMath);

  deployer.link(Ownable, Payroll);
  deployer.link(SafeMath, Payroll);
  deployer.deploy(Payroll);
};

执行编译

trffle migrate

打开测试客户端 testrpc

交互

truffle console 
# 调用web3 获取地址
web3.eth.accounts
# 执行添加方法
payroll.addRmployee('0xasdasdas2qwa0sd9uvnmaos',2)
# 查看信息
paroll.employees.call('0xasdasdas2qwa0sd9uvnmaos').then(result=>console.log)

Copyright © 2019- huatuo9.cn 版权所有 赣ICP备2023008801号-1

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务