Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Latest commit

History

History

39-Multicall

README.md

Multicall

Multicall aggregates results from multiple contract constant function calls. This reduces the number of separate JSON RPC requests that need to be sent (especially useful if using remote nodes like Infura), while also providing the guarantee that all values returned are from the same block (like an atomic read) and returning the block number the values are from (giving them important context so that results from old blocks can be ignored if they're from an out-of-date node).

This smart contract is intended to be used with Multicall.js in front-end dapps

He Yue Diao Yong Fang Fa

He Yue Zhi Jian De Diao Yong You 2 Chong Fang Shi : Di Ceng De call Fang Shi He new He Yue De Fang Shi

call:Tong Guo He Yue ContractAddres.call(Bian Ma Hou De Fang Fa Ming He Can Shu ),Fan Hui Diao Yong Shi Fou Cheng Gong ,Yi Ji Fan Hui Zhi data

delegatecall :She Ji Shi Wei Liao Diao Yong Qi Ta He Yue De API Yong De ,Lei Si Yu Copy Liao API He Yue De API Han Shu Dao Ben Di He Yue Zhi Xing ,Hui Xiu Gai Diao Yong Zhe He Yue De Zhuang Tai Bian Liang .

staticcall: Since byzantium staticcall can be used as well. This is basically the same as call, but will revert if the called function modifies the state in any way eth.call Fang Fa Ke Yi Zai Ben Di Jie Dian Zhi Xing Fang Fa ;

Multicall.js

Multicall.js Shi Yi Ge Qing Liang Ji De JavaScript Ku , Yong Yu Yu Duo Ge Zhi Neng He Yue Jin Xing Jiao Hu . Multicall.js Ku Ju You Yi Xia Zhe Xie Te Dian :

  • Zai Yi Ci Diao Yong Zhong Huo Qu Duo Ge Zhi Neng He Yue Han Shu Diao Yong De Fan Hui Zhi
  • Bao Zheng Suo You Zhi Du Lai Zi Tong Yi Ge Kuai
  • Shi Yong Guan Cha Zhe Lun Xun Duo Ge Qu Kuai Lian Zhuang Tai Bian Liang /Han Shu
  • Dang Guan Cha Zhe Jian Ce Dao Zhuang Tai Fa Sheng Bian Hua Shi Huo Qu Geng Xin
  • Bu Tong Bu Jie Dian De Jie Guo Hui Bei Zi Dong Hu Lue
  • Huo Qu Xin De Qu Kuai Geng Xin

indexed-finance-multicall.js

Yu Chang Gui Muticall He Yue Diao Yong Bu Tong ,indexed-finance multicall Bu Yong Yi Lai Lian Shang Yi Jing Bu Shu Cheng Gong De multicall He Yue ,Er Shi Jiang muticall Qing Qiu Fang Dao Liao Dai Bu Shu He Yue De constructor Zhong ,Tong Guo Jia Bu Shu De Fang Shi ,Na Dao Lian Shang Cha Xun De Jie Guo .
indexed-finance multicall De "Sao Cao Zuo ":

  1. constructor Zhong Jin Xing muticall Qing Qiu
  2. Li Yong assembly Xiu Gai evm De Fan Hui Shu Ju ,Ti Huan Wei muticall Qing Qiu Jie Guo
    • Shi Yong eth_call Zhi Xing Jiao Yi ,Zai EVM Zhong Hui Xian Zhi Xing ,Zai Hui Tui Jiao Yi Zhuang Tai
contract MultiCall {
constructor(
address[] memory targets,
bytes[] memory datas
) public {
uint256 len = targets.length;
require(datas.length == len, "Error: Array lengths do not match.");

bytes[] memory returnDatas = new bytes[](len);

for (uint256 i = 0; i < len; i++) {
address target = targets[i];
bytes memory data = datas[i];
(bool success, bytes memory returnData) = target.call(data);
if (!success) {
returnDatas[i] = bytes("");
} else {
returnDatas[i] = returnData;
}
}
bytes memory data = abi.encode(block.number, returnDatas);
assembly { return(add(data, 32), data) } // @notice: Zhe Li Shi Sao Cao Zuo
}
}

Ce Shi Bu Zou

  • An Zhuang Yi Lai
yarn
  • Pei Zhi Huan Jing Bian Liang
cp .env.example .env

## Pei Zhi .evn Wen Jian Zhong De INFURA_ID
  • Ce Shi makerdao-multicall.js
npx hardhat run scripts/makerdao-multicall.js
  • Ce Shi indexed-finance-multicall.js
npx hardhat run scripts/indexed-finance-multicall.js
  • Dan Yuan Ce Shi
npx hardhat test --network mainnet

TODO: https://github.com/Vectorized/multicaller/blob/main/src/MulticallerWithSender.sol

Can Kao Lian Jie