Smart contract 로 토큰전송 하고싶은데 잘 안됩니다

const Caver = require(‘caver-js’)
const caver = new Caver(process.env.CEIK_RPC)

////////////////////////////////////////////////////////////////
const receiverAddress = “0x7C720ca152B43fa72a24eCcd51ccDAFBF74A884e”; // CLIP
const senderAddress = “0x0011A1cad2cA5d23Fde3cc0DefB10e1a8C3Df0c4”; // 윈스톰 법사 CEIK
const ceik_contract_abi = require("./ceikABI.json");
const ceik_tokenAddress = “0x18814b01b5cc76f7043e10fd268cc4364df47da0”; // ceik
const ceik_tokenABI = “0x9166c8d72e513a9e3b8389c11481ec071da93e37370fc62bf99c51a7b869a7dd”;
const sendCEIK = (caver.utils.toPeb(1, ‘KLAY’) *0.0000000001); // 1 CEIK

async function fn_unlockAccount_token(addr){
let rtn_result = false;
await caver.klay.personal.unlockAccount(addr, process.env.C4EI_ADDR_PWD, 500).then(function (result) {
rtn_result = result;
console.log(‘fn_unlockAccount_token result :’ + result);
});
return await rtn_result;
}
async function sendTokenKLAY_CEIK(){
if (await fn_unlockAccount_token(senderAddress)){
await sendToken();
}
}
async function sendToken(){
const TokenInstance = new caver.klay.Contract(ceik_contract_abi, ceik_tokenAddress)
TokenInstance.methods.transfer(receiverAddress, sendCEIK)
.send({from: senderAddress,gas: 100000})
.then(function(receipt){
console.log(“blockNumber " + receipt.blockNumber + " / contractAddress” + receipt.contractAddress + " / blockHash" + receipt.blockHash + " / transactionHash" + receipt.transactionHash);
})
// .on(‘transactionHash’, (hash) => { console.log("### transactionHash ###"); console.log(hash);})
// .once(‘receipt’, (receipt) => {console.log(“blockNumber " + receipt.blockNumber + " / contractAddress” + receipt.contractAddress + " / blockHash" + receipt.blockHash + " / transactionHash" + receipt.transactionHash);})
// .on(‘confirmation’, (confirmationNumber, receipt) => { console.log("### confirmation ###" + confirmationNumber);})
// .on(‘error’, console.error)
;
}

sendTokenKLAY_CEIK();
////////////////////////////////////////////////////////////////

결과
dev@ubuntu:~/www/geth-to-mysql$ node sendceik

node sendCEIK start

fn_unlockAccount_token result :true
blockNumber 77816312 / contractAddressnull / blockHash0x2f1d68170e250021877351e559453c8c9c535f0e64ce9b418b4d86c86576f886 / transactionHash0xaa3cadab85c0dcbb2cb239d6fd50b937cd2850aa689bf3e984e981f8124b9337

저기 contractAddress가 null 인데 . . . ?..?ㅋ 음 . . .맞는 건가요?

잘 되는거였군요 (__) 감사합니다.

@c4ei

:slight_smile: 확인해주시고 답 남겨주셔서 감사합니다.

1 Like