编写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)
网友评论