Skip to content

Instantly share code, notes, and snippets.

View w3kim's full-sized avatar

Eric Woojung Kim w3kim

  • Waterloo, ON, Canada
View GitHub Profile
@w3kim
w3kim / blockfilter.js
Created October 18, 2019 01:03
Filtering transactions that are included in a block
const Caver = require('caver-js');
const caver = new Caver('https://api.baobab.klaytn.net:8651/');
// getBlock's second parameter is boolean; if true, getBlock returns a block with transaction objects.
caver.klay.getBlock(9660831, true).then((resp) => {
const { transactions } = resp;
const filtered = transactions.filter((e) => { return e['to'] === 'address_you_are_looking_for' });
console.log(filtered);
});
package com.klaytn.example.caver;
import com.klaytn.caver.Caver;
import com.klaytn.caver.crpyto.KlayCredentials;
import com.klaytn.caver.fee.FeePayerManager;
import com.klaytn.caver.methods.response.KlayTransactionReceipt;
import com.klaytn.caver.tx.gas.DefaultGasProvider;
import com.klaytn.caver.tx.manager.PollingTransactionReceiptProcessor;
import com.klaytn.caver.tx.model.ValueTransferTransaction;
@w3kim
w3kim / fee_delegated_contract_deploy.js
Last active April 5, 2020 14:16
Klaytn: deploying smart contract with fee delegation
const Caver = require('caver-js');
const caver = new Caver('https://api.baobab.klaytn.net:8651/');
const sender = caver.klay.accounts.wallet.add('sender_private_key');
const payer = caver.klay.accounts.wallet.add('fee_payer_key', 'target_address');
// an arbitrary contract is used
async function run() {
// make sure `data` starts with 0x
const { rawTransaction: senderRawTransaction } = await caver.klay.accounts.signTransaction({
@w3kim
w3kim / greeter.js
Created October 7, 2019 09:23
Klaytn: Check the Deployment Example
// 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);
@w3kim
w3kim / caver-js_bytes32.js
Created October 1, 2019 02:17
Using bytes32 with caver-js
const Caver = require('caver-js');
const caver = new Caver('https://api.baobab.klaytn.net:8651');
const acct = caver.klay.accounts.privateKeyToAccount('your_private_key')
caver.klay.accounts.wallet.add(acct)
/*
We will use the following contract to demonstrate the use of bytes32:
pragma solidity 0.4.24;