代币合约DAPP项目系统开发(技术方案)
导读: 区块链是从BTC系统中提炼出来的一种底层支撑技术,Token原本是区块链上激励“矿工”的一种经济手段,在加密数字货币的发展过程中,有大量的组织也希望能够发行自己的Token,区块链2.0——ETH及其订立的ERC20标准应用而生,基于这...
区块链是从BTC系统中提炼出来的一种底层支撑技术,Token原本是区块链上激励“矿工”的一种经济手段,在加密数字货币的发展过程中,有大量的组织也希望能够发行自己的Token,区块链2.0——ETH及其订立的ERC20标准应用而生,基于这个平台和标准,任何人和组织都可以在ETH上发行自己定义的Token,极大地降低了发行的难度和速度,Token开始以代币的身份为大众所熟知。
Deployer API deployer对象提供了方法用于简化智能合约的部署。deployer.deploy(contract,args…,options)参数contract为使用artifacts.require引用的智能合约对象。参数args...为智能合约的构造函数的参数,用于初始化智能合约。参数options用于指定from,gas及overwrite等信息,overwrite用于重新部署某个已经完成部署的智能合约,默认的options参数在bottle.js文件中配置
例子:
//Deploy a single contract without constructor arguments
deployer.deploy(A);
//Deploy a single contract with constructor arguments
deployer.deploy(A,arg1,arg2,...);
//Don't deploy this contract if it has already been deployed
deployer.deploy(A,{
overwrite:false}
);
//Set a maximum amount of gas and`from`address for the deployment
deployer.deploy(A,{
gas:4612388,from:"0x...."}
);
//External dependency example:
//
//For this example,our dependency provides an address when we're deploying to the
//live network,but not for any other networks like testing and development.
//When we're deploying to the live network we want it to use that address,but in
//testing and development we need to deploy a version of our own.Instead of writing
//a bunch of conditionals,we can simply use the`overwrite`key.
deployer.deploy(SomeDependency,{
overwrite:false}
);
通过promise对象可以运行任意的部署步骤并调用指定的智能合约内部方法来进行交互
例子:
var ERC20=artifacts.require("../contracts/Erc20.c")
module.exports=function(deployer,a){
deployer.deploy(ERC20,"1000000","bitcoin","BTC").then(function(instance){
deploy=instance;
return deploy.GetTotalSupply()
}
).then(function(totalSupply){
console.log("totalSupply",totalSupply.toString());
return deploy.GetDecimals();
}
).then(function(decimals){
console.log("decimals",decimals.toString());
return deploy.GetTokenName();
}
).then(function(tokenName){
console.log("tokenName",tokenName);
return deploy.GetAmount("0x122369f04f32269598789998de33e3d56e2c507a")
}
).then(function(balance){
console.log("balance",balance.toString());
}
)
}
;
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: 代币合约DAPP项目系统开发(技术方案)
本文地址: https://pptw.com/jishu/3357.html