안녕하세요 Polygon Network에 배포했던 컨트랙트들을 Klaytn으로 마이그레이션을 하려고하는데요.
현재 truffle을 이용해서 배포를 시도했으나 https://devforum.kaia.io/t/truffle-gas-limit/2246 해당 이슈와 같은 에러로 배포에 실패하여, Klaytn IDE로 배포를 완료하였습니다.
그렇게 완료한 컨트랙트 주소에 대해서 KAS 계정을 연동하여 Caver-JS로 Contract Execution을 실행하면 다음과 같은 에러를 발생시키는데요.
에러 정보가 다소 제한적이어서 원인을 모르겠어서 문의드립니다.
코드 일부와 에러 정보를 첨부하겠습니다
Error: Invalid JSON RPC response: {“id”:8,“jsonrpc”:“2.0”}
const partyContract = '0x0f481Cd16d1a9e256A94125f7fFb4bA301f2CD7D';
const metadataContract = '0xc87e49Fcf171Ef6E48a748e4e7c74329f73D563c';
const mnemonic = 'frog error again lesson blue arrest cement attitude world firm leopard believe';
const currentAdmin = '0x96d34422e1c68f732af14EbCf1cb31AcA03cFA57';
const BN = require('bn.js');
const HDWalletProvider = require("truffle-hdwallet-provider-klaytn");
const Caver = require('caver-js');
const option = {
headers: [
{
name: "Authorization",
value:
"Basic " +
Buffer.from('KASKUBWYC5R5MBCEZFBS97IN' + ":" + 'WL2wegSoCGwVJIGG9_vku247hu8V4AwvfnWcCOVY').toString(
"base64"
),
},
{ name: "x-chain-id", value: "1001" },
],
keepAlive: false,
};
const httpProvider = new HDWalletProvider(
mnemonic,
new Caver.providers.HttpProvider(
"https://node-api.klaytnapi.com/v1/klaytn",
option
)
);
const caver = new Caver(httpProvider);
const abi = [
{
"constant": true,
"inputs": [],
"name": "isOwner",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [],
"name": "unpause",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
{
"constant": true,
"inputs": [],
"name": "paused",
"outputs": [
{
"name": "",
"type": "bool"
}
],
"payable": false,
"stateMutability": "view",
"type": "function"
},
{
"constant": false,
"inputs": [
{
"name": "_address",
"type": "address"
}
],
"name": "setRescuerContract",
"outputs": [],
"payable": false,
"stateMutability": "nonpayable",
"type": "function"
},
]
const metadataInstance = new caver.contract(abi, metadataContract);
async function deploySet() {
try {
let fromNonce = await caver.klay.getTransactionCount(currentAdmin);
console.log(fromNonce);
let res = await metadataInstance.methods.isOwner().call({nonce: fromNonce, from: currentAdmin, gas: 1000000})
console.log(res)
fromNonce = await caver.klay.getTransactionCount(currentAdmin);
console.log(fromNonce)
let estimatedGas = await metadataInstance.methods.setRescuerContract(partyContract).estimateGas({from: currentAdmin, gas: 10000000})
// let estimatedGas = await metadataInstance.methods.unpause().estimateGas({from: currentAdmin, gas: 100000000})
console.log(estimatedGas)
res = await metadataInstance.methods.setRescuerContract(partyContract).send({from: currentAdmin, gas: estimatedGas})
// let res = await metadataInstance.send({nonce: fromNonce, from: currentAdmin, gas: 1000000}, 'setRescuerContract', partyContract);
// console.log(res)
// res = await metadataInstance.methods.unpause().send({from: currentAdmin, gas: 100000000});
// res = await metadataInstance.send({from: currentAdmin, gas: 100000000}, 'unpause');
console.log(res)
return
} catch(e) {
console.log("err 발생")
console.log(e)
return
}
}
deploySet()