Created
October 7, 2019 09:23
-
-
Save w3kim/ccb0bdcf5adff81f7f31e70f3c11813e to your computer and use it in GitHub Desktop.
Klaytn: Check the Deployment Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The following example is a modified version of | |
// the one introduced on https://docs.klaytn.com/getting-started/quick-start/check-the-deployment | |
const Caver = require('caver-js'); | |
const caver = new Caver('https://api.baobab.klaytn.net:8651'); // using Baobab testnet | |
const contractAddress = '0x799599e8170f210af2c85187bacd070751cb114a' // pre-deployed contract | |
caver.klay.getCode(contractAddress).then(console.log); | |
const abi = [ | |
{ | |
"constant": false, | |
"inputs": [], | |
"name": "kill", | |
"outputs": [], | |
"payable": true, | |
"stateMutability": "payable", | |
"type": "function" | |
}, | |
{ | |
"inputs": [ | |
{ | |
"name": "_greeting", | |
"type": "string" | |
} | |
], | |
"payable": false, | |
"stateMutability": "nonpayable", | |
"type": "constructor" | |
}, | |
{ | |
"constant": true, | |
"inputs": [], | |
"name": "greet", | |
"outputs": [ | |
{ | |
"name": "", | |
"type": "string" | |
} | |
], | |
"payable": false, | |
"stateMutability": "view", | |
"type": "function" | |
} | |
]; // ABI | |
const klaytnGreeter = new caver.klay.Contract(abi, contractAddress); | |
klaytnGreeter.methods.greet().call().then(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment