// this txid is an example.consttxid='c45edfcca86f4f528cd8e30634fa4ac53801aae05365cfefc3bfe9b652fe5768';aelf.chain.getTxResult(txid, (err, result) => {console.log('>>>>>>>>>>>>> getTxResult >>>>>>>>>>>>>');console.log(err, result);});// result = {// Status: "NotExisted"// TransactionId: "c45edfcca86f4f528cd8e30634fa4ac53801aae05365cfefc3bfe9b652fe5768"// ....// }
3.4 INIT_AELF_CONTRACT
// In aelf-sdk.js wallet is the realy wallet.// But in extension sdk, we just need the address of the wallet.constwallet= { address:'2JqnxvDiMNzbSgme2oxpqUFpUYfMjTpNBGCLP2CsWjpbHdu'};// It is different from the wallet created by Aelf.wallet.getWalletByPrivateKey();// There is only one value named address;aelf.chain.contractAt('4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', wallet, (error, result) => {console.log('>>>>>>>>>>>>> contractAt >>>>>>>>>>>>>');console.log(error, result); tokenContract = result; });// result = {// Approve: ƒ (),// Burn: ƒ (),// ChargeTransactionFees: ƒ (),// ClaimTransactionFees: ƒ (),// ....// }
// tokenContract from the pre step.tokenContract.GetBalance.call( { symbol:'AELF', owner:'65dDNxzcd35jESiidFXN5JV8Z7pCwaFnepuYQToNefSgqk9' }, (err, result) => {console.log('>>>>>>>>>>>>>>>>>>>', result); });tokenContract.Approve( { symbol:'AELF', spender:'4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc', amount:'100' }, (err, result) => {console.log('>>>>>>>>>>>>>>>>>>>', result); });// If you use tokenContract.GetBalance.call this method is only applicable to queries that do not require extended authorization validation.(CALL_AELF_CONTRACT_READONLY)
// If you use tokenContract.Approve this requires extended authorization validation (CALL_AELF_CONTRACT)// tokenContract.GetBalance.call(payload, (error, result) => {})// result = {// symbol: "AELF",// owner: "65dDNxzcd35jESiidFXN5JV8Z7pCwaFnepuYQToNefSgqk9",// balance: 0// }
3.6 CHECK_PERMISSION
CHECK_PERMISSION returns the contracts your can use with the address.
aelf.checkPermission({ type:'address',// if you did not set type, it aways get by domain. address:'4WBgSL2fSem9ABD4LLZBpwP8eEymVSS1AyTBCqXjt5cfxXK'}, (error, result) => {console.log('>>>>>>>>>>>>>', error, result);});// result = {// ...,// permissions:[// {// address: '...',// appName: 'hzzTest',// contracts: [{// chainId: 'AELF',// contractAddress: '4rkKQpsRFt1nU6weAHuJ6CfQDqo6dxruU3K3wNUFr6ZwZYc',// contractName: 'token',// description: 'token contract',// github: ''// },// {// chainId: 'AELF TEST',// contractAddress: 'TEST contractAddress',// contractName: 'TEST contractName',// description: 'contract description',// github: ''// }],// domian: 'Dapp domain'// }// ]// }
3.7 SET_CONTRACT_PERMISSION
SET_CONTRACT_PERMISSION applies to the users to allow the Dapp use the contract.