🥁 Batch contract/on-chain queries to the same block. Multicall SDK for the Klaytn blockchain.

Overview

Cover Image

Klaytn Multicall

Built for inevitable-changes/bento
Inspired by makerdao/multicall and dopex-io/web3-multicall

📦 Installation

# Yarn
yarn install klaytn-multicall

# NPM
npm install klaytn-multicall

🚀 Usage

import { Multicall } from 'klaytn-multicall';

const caver = new Caver(...);
const multicall = new Multicall({ provider });

const staking = new caver.klay.Contract(...);
const calls = [
  staking.methods.balanceOf(
    '0x7777777141f111cf9f0308a63dbd9d0cad3010c4',
  ),
  staking.methods.rewardsOf(
    '0x7777777141f111cf9f0308a63dbd9d0cad3010c4',
  ),
];

await multicall.aggregate(calls)
  .then((console.log));

Helpers live inside

  • getEthBalance: Gets the ETH KLAY balance of an address
  • getBlockHash: Gets the block hash
  • getLastBlockHash: Gets the last blocks hash
  • getCurrentBlockTimestamp: Gets the current block timestamp
  • getCurrentBlockDifficulty: Gets the current block difficulty
  • getCurrentBlockGasLimit: Gets the current block gas limit
  • getCurrentBlockCoinbase: Gets the current block coinbase
const multicall = new Multicall({ provider });

const calls = [
  staking.methods.balanceOf('0x7777777141f111cf9f0308a63dbd9d0cad3010c4'),
  staking.methods.rewardsOf('0x7777777141f111cf9f0308a63dbd9d0cad3010c4'),

  // Queries KLAY balance of address
  multicall.contract.methods.getEthBalance(
    '0x7777777141f111cf9f0308a63dbd9d0cad3010c4',
  ),
  multicall.contract.methods.getBlockHash(103742609),
  multicall.contract.methods.getLastBlockHash(),
];

await multicall.aggregate(calls).then(console.log);

Customization

You can inject contract address of your custom implementation, too:

new Multicall({
  provider,
  multicallV2Address: '0xd11dfc2ab34abd3e1abfba80b99aefbd6255c4b8',
});

multicallV2Address defaults to 0xd11dfc2ab34abd3e1abfba80b99aefbd6255c4b8(Multicall2 deployed in Cypress).

You might also like...

An ERC-721 like NFT contract with Plutus scripts and Lucid as off-chain framework

Gatsby minimal TypeScript starter 🚀 Quick start Create a Gatsby site. Use the Gatsby CLI to create a new site, specifying the minimal TypeScript star

Sep 23, 2022

Pull a smart contract from mainnet onto your local chain.

hardhat-copy hardhat-copy helps you import an Ethereum mainnet smart contract onto your local Hardhat node, enabling you to rapidly experiment with pr

Aug 21, 2022

This SDK helps developers get started with the on-chain tools provided by Metaplex.

This SDK helps developers get started with the on-chain tools provided by Metaplex.

Metaplex JavaScript SDK ⛔️ DO NOT USE IN PRODUCTION, THIS SDK IS IN VERY EARLY ALPHA STAGES! This SDK helps developers get started with the on-chain t

Dec 27, 2022

A module federation SDK which is unrelated to tool chain for module consumer.

A module federation SDK which is unrelated to tool chain for module consumer.

hel-micro, 模块联邦sdk化,免构建、热更新、工具链无关的微模块方案 Demo hel-loadash codesandbox hel-loadash git Why hel-micro 如何使用远程模块 仅需要一句npm命令即可载入远程模块,查看下面例子线上示例 1 安装hel-micr

Jan 3, 2023

On-chain snapshots of the whole blockchain state

📸 Snapshop 📸 Snapshop is a tool for creating on-chain snapshots of the whole blockchain state. It lets your smart contracts read the storage of any

Sep 26, 2022

Cupcakes SDK to allow developers access to Authentication & Smart Contract Wallets

Introduction Cupcakes allow DAPPs developers access to Smart Contract Wallets. These wallets can be DAPPs specific or User specific. You must read abo

Nov 26, 2022

The iofod SDK provides developers with the ability to interact with the main iofod interface within the Web worker, enabling rapid development of iofod extensions through the SDK.

iofod-sdk English | 简体中文 The iofod SDK provides developers with the ability to interact with the main iofod interface within the Web worker, enabling

Oct 17, 2022

Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's `move-ts`.

Movehat Movehat is a TypeScript SDK for Move on Sui built on top of Sui's TypeScript SDK and our fork of Ian Macalinao's move-ts. Movehat aspires to b

Sep 30, 2022

Blockchain, Smart Contract, Ganache, Remix, Web3, Solidity, Java Script, MQTT, ESP32, RFID, DHT11,

Blockchain, Smart Contract, Ganache, Remix, Web3, Solidity, Java Script, MQTT, ESP32, RFID, DHT11,

May 24, 2022
Comments
Owner
Inevitable (Bento)
⚡️ The team of web3 builders and also the universe — not tied by borders, laws, or to any L1
Inevitable (Bento)
chain-syncer is a module which allows you to synchronize your app with any ethereum-compatible blockchain/contract state. Fast. Realtime. Reliable.

Chain Syncer Chain Syncer is a JS module which allows you to synchronize your app with any ethereum-compatible blockchain/contract state. Fast. Realti

Miroslaw Shpak 10 Dec 15, 2022
Supercharge Multicall.js with nitro features 💨

multicall-nitro Supercharge Multicall.js with nitro features ?? Highlights TypeScript support ✅ Ready-to-use calls ✍?? React hook ⚛️ One time call ??

Enzo Ferey 5 Dec 15, 2022
Frontend landing page for Bento's Klaytn Launch in Klaymakers 2022

Bento Dashboard for Klaytn Fi+ Frontend landing page for Bento's Klaytn Launch in Klaymakers 2022 ??️ Licensing All our branding resources(such as tra

Inevitable (Bento) 3 Oct 26, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Generate deterministic fake values: The same input will always generate the same fake-output.

import { copycat } from '@snaplet/copycat' copycat.email('foo') // => '[email protected]' copycat.email('bar') // => 'Thurman.Schowalter668@

Snaplet 201 Dec 30, 2022
A block preview that directly displays the block fields, including tabs.

Kirby Block Preview Fields This plugin for Kirby 3 displays the block fields directly in the block preview, including tabs. Inspired by the Kirby Fiel

JUNO 8 May 10, 2023
SmartBuilder: A Block-based Visual Programming Framework for Smart Contract Development

SmartBuilder A Block-based Visual Programming Framework for Smart Contract Development Technology stack used SmartBuilder Framework - Google Blockly A

ibelab 4 Mar 29, 2022
Detect if a contract has been deployed in the latest (or predefined) block from an address that was previously funded through Tornado.Cash.

??️‍♂️ TORN Detector Detect if a contract has been deployed in the latest (or predefined) block from an address that was previously funded through Tor

Pascal Marco Caversaccio 14 Dec 24, 2022