composer 引入
composer require kgs/web3 'dev-master'
合约 *** 作
//查询代币余额
$coin_info = [
'host'=>'节点',
'abi'=>'对应合约abi',
'address'=>'对应合约地址',
];
$web = new Web3($coin_info['host']);
$contract = Contract::at($web,$coin_info['abi'],$coin_info['address']);
$s = $contract->call('balanceOf',[$address]);
//代币转账
$web = new Web3($coin_info['host']);
$wallet = Wallet::createByPrivate($keyPrivate); //私钥
$contract = Contract::at($web,$coin_info['abi'],$coin_info['address']);
$reStr = $contract->send($wallet,'transfer',[$to,$money]);//转账地址 和 数量 注意数量单位
//查询hash状态
$web3 = new Web3($host);
$e = $web3->getTransactionReceipt($hash);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)