Comments (2)
senToken function is used to create an unsigned TRC10 token transfer transaction.
If you want to create a TRC20 transfer transaction, use the triggersmartcontract function.
Please refer to this link for how to use it.
https://developers.tron.network/reference#triggersmartcontract
from tronweb.
@StarLXL Thank you for your reply!
I have write a demo like blew:
const privateKey = '5bcf9b39c69bf374c0441f06cfcd7b28a5ea6c6018c5eeace591f4db75e4dd01';
const tronWeb = new TronWeb({
fullHost: 'https://api.shasta.trongrid.io',
});
const anthoerTronAddress = 'TX1mBCZSdXzggYcV16yEZ39L9wpF8eEmgo';
const isuuerAddres = 'TMPgjknWZsYJSmPjpY5V33qmKoruUqcYA3';
const contractAddress = 'TLdPQwEeTAaCfNrGRBhmxnScDmfZL2Perz';
async function main() {
try {
const parameter = [{ type: 'address', value: anthoerTronAddress }, { type: 'uint256', value: '10000000000000000' }];
const options = {
feeLimit: 100000000,
callValue: 0,
};
const transaction = await tronWeb.transactionBuilder.triggerSmartContract(tronWeb.address.toHex(contractAddress), 'transfer(address,uint256)', options, parameter, tronWeb.address.toHex(isuuerAddres));
if (!transaction.result || !transaction.result.result) {
throw new Error('transaction crated failed');
}
const signedTransaction = await TronWeb.utils.crypto.signTransaction(privateKey, transaction.transaction);
const broadcast = await tronWeb.trx.sendRawTransaction(signedTransaction);
} catch (error) {
console.log('Error', error);
}
}
main();
It is ok if transfer a trc20 token from contract isuuerAddres
to another anthoerTronAddress
.
What if I want to transfer trc20 token between two non-issuer accounts, what triggerSmartContract function params should like?
I have tried change triggerSmartContract issuerAddress param to anthoerTronAddress
.
when i Broadcast, i got an error:
[ { "apiRet": { "code": "SIGERROR", "message": "validate signature error b483c6900340d6ee838b08a54cb9a605cab087bfe5a0ca5b9d0c7da24a8f1f750af727100138bc7105202b86ee9e8b918af93172f7e479ab2620c71d63ec486100 is signed by TYEQ1Xc3ejLHnEPWa9YpH1jMWSHoNhW5t7 but it is not contained of permission.", "txid": "e747645a2716d9fb45210cab9255ff43928ccfac8dbbd024b20c72e80805665c" }, "broadcastTime": 1589513194, "id": 2 } ]
Is this function can only call by contract issuer?
from tronweb.
Related Issues (20)
- www/wwwroot/yhnew/yuanma2/public/index.php QUERY_STRING s=/index/links/index.html
- Error [ERR_REQUIRE_ESM]: require() of ES Module secp256k1/index.js from TronWeb.node.js HOT 12
- Error tronWeb.trx.getBalance(address) HOT 6
- [Feature] Think about separate TronWeb into 2 versions - For NodeJS and For Browser. HOT 5
- Project don't have stable version for production (axios, @noble/secp256k1) HOT 2
- multisign transactionBuilder.sendTrx not send any transaction
- multiSign for Contracts return invalid transaction
- multiSign for Contracts return invalid transaction HOT 3
- Invalid address in TRC20 Token HOT 10
- Error messages determination and handling HOT 3
- I am getting OUT OF ENERGY Error HOT 1
- How to actually calculate the amount of resources for a transaction? HOT 6
- An error occurred while running in nodejs HOT 1
- How to proper decode a smart contract input data? HOT 3
- Tronscan
- Why types are not exported?! HOT 4
- Allow raw axios headers HOT 2
- Invalid type for block.transactions HOT 2
- Error [ERR_REQUIRE_ESM]: require() of ES Module
- TypeError: TronWeb is not a constructor HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tronweb.