|-----------------------------------------------------------------------------------------------------------------------------------------
|【说明】:我们要部署一条charge模型的测试链
| 【目标】:
| 1.交易手续费用发放到共识节点
| 2.admin能够进执行自动执行操作
| 3.普通节点能够发送交易、部署合约、调用合约
| 4.发行一定数量的原生token到admin账户
| 5.部署测试合约
|【说明2】:前两章,我们部署了一条charge模型的测试链,本章在此基础上,进行测试合约的部署
|【声明】:
| 感谢您的阅读,如果文中的内容有描述不当或者存在疑虑,请在留言区回复,我会及时进行更正
|-------------------------------------------------------------------------------------------------------------------------------------------
一、编辑合约在线网址
测试合约内容:
contract Person{
uint public age=10;
string public name = "";
function increseAge()public returns (uint){
return ++age;
}
function getAget()public returns(uint){
return age;
}
function say()public returns (string){
return "hello";
}
}
点击Details显示如下界面:
二、部署合约
rpc sendRawTransaction --code 0x6080604052600a60005560206040519081016040528060008152506001908051906020019061002f929190610042565b5034801561003c57600080fd5b506100e7565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061008357805160ff19168380011785556100b1565b828001600101855582156100b1579182015b828111156100b0578251825591602001919060010190610095565b5b5090506100be91906100c2565b5090565b6100e491905b808211156100e05760008160009055506001016100c8565b5090565b90565b61033e806100f66000396000f30060806040526004361061006d576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806306fdde0314610072578063262a9dff146101025780636d009f291461012d578063954ab4b214610158578063a01de6ab146101e8575b600080fd5b34801561007e57600080fd5b50610087610213565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156100c75780820151818401526020810190506100ac565b50505050905090810190601f1680156100f45780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561010e57600080fd5b506101176102b1565b6040518082815260200191505060405180910390f35b34801561013957600080fd5b506101426102b7565b6040518082815260200191505060405180910390f35b34801561016457600080fd5b5061016d6102cc565b6040518080602001828103825283818151815260200191508051906020019080838360005b838110156101ad578082015181840152602081019050610192565b50505050905090810190601f1680156101da5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b3480156101f457600080fd5b506101fd610309565b6040518082815260200191505060405180910390f35b60018054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156102a95780601f1061027e576101008083540402835291602001916102a9565b820191906000526020600020905b81548152906001019060200180831161028c57829003601f168201915b505050505081565b60005481565b60008060008154600101919050819055905090565b60606040805190810160405280600581526020017f68656c6c6f000000000000000000000000000000000000000000000000000000815250905090565b600080549050905600a165627a7a72305820d3ea6379de354182945b0435d658b4efbed45d69310553d4385b2a162d284bf00029 --private-key 0x195d11f76cd552cf911fed11128085f5bca3566c153a508a71c8412e93231dd7
【参数说明】:
–code,指的是合约数据;
--private-key,指的是合约创建者的私钥;
【注意】:部署合约时,需要保证部署合约账户中存在足够的余额
执行rpc getTransactionReceipt --hash 获取交易回执,查看交易处理后的结果信息
得到合约地址contractAddress: 0xad5cdfa04759e93486e86c50c846bbcaf28179a4
三、调用合约函数
rpc sendRawTransaction --code 0xa01de6ab --private-key 0x195d11f76cd552cf911fed11128085f5bca3566c153a508a71c8412e93231dd7 --address 0xad5cdfa04759e93486e86c50c846bbcaf28179a4
【参数说明】:
--code,指的是合约函数地址,在编译合约时可获取;
--private-key,指的是合约创建者的私钥;
--address,指的是合约地址
四、查询调用结果
rpc call --to 0xad5cdfa04759e93486e86c50c846bbcaf28179a4 --data 0xa01de6ab
【参数说明】:–to合约地址;–data调用的合约函数地址
【声明】:
感谢您的阅读,如果文中的内容有描述不当或者存在疑虑,请在留言区回复,我会及时进行更正