[英]JSON rpc transaction for Tokens
I have implemented transactions using ETH, however, I want to exchange tokens between accounts. 我已经使用ETH实现了交易,但是,我想在账户之间交换令牌。 Here is my code
这是我的代码
var postData = {"jsonrpc":"2.0","method":"eth_sendTransaction","params": [{"from":"0x52f273a06a420453aa5b33c4f175395c9a1fddd8", "to": data.ethAddress, "value": 1e18}], "id":1}
var url = 'http://localhost:8545/'
var options = {
method: 'post',
body: postData,
json: true,
url: url
}
request(options, function (err, res, body) {
if (err) {
console.error('error posting json: ', err)
throw err
}
var headers = res.headers
var statusCode = res.statusCode
console.log('headers: ', headers)
console.log('statusCode: ', statusCode)
console.log('body: ', body)
})
This is completing the transaction with 1 ETH being transferred between accounts. 这将完成交易,并在帐户之间转移1 ETH。 However, I want to setup this same action but with my custom token as the currency, not ETH.
但是,我想设置相同的操作,但是用我的自定义令牌作为货币,而不是ETH。 Any help would be greatly appreciated.
任何帮助将不胜感激。 Thanks
谢谢
I am not sure if that is what you need... You can create a class or two either in C# or in JavaScript to reflect all your properties. 我不确定这是否是您需要的...您可以使用C#或JavaScript创建一两个类,以反映您的所有属性。
var whatever= {};
whatever.jsonrpc="2.0";
whatever.id=1;
whatever.method="eth_sendTransaction";
whatever.params= [];
whatever.params[0].from="0x52f273a06a420453aa5b33c4f175395c9a1fddd8";
whatever.params[0].to=data.ethAddress;
whatever.params[0].value=1e18;
whatever.params[0].currency="xxx";
etc 等等
I understand that you want to send your token (currency) among different accounts. 我了解您想在不同的帐户之间发送令牌(货币)。 So, I imagine that you have created your own token and that you have developed your code (your Smart Contract).
因此,我想您已经创建了自己的令牌并且已经开发了代码(您的智能合约)。
Then, you should deploy your code and start using it. 然后,您应该部署代码并开始使用它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.