1
aggron 2022-11-04 17:37:39 +08:00 1
1. 会算 gas
2. 复制到自己合约内调用,比直接调用外部合约省 gas ,外部合约初始化 |
2
cxh116 OP @aggron 感谢感谢.刚实测了也确实是复制到自己合约里更省.
test1 gas 25,448 test2 gas 23,055 // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import './HelloWorld.sol'; contract TestCall { function test1(string memory p1) external returns (string memory ret) { ret = IHelloWorld(0x93e3EC5b5087bFcaBCcA95Fce30a094dEaEaA13B).get(); } function test2(string memory p1) external returns (string memory ret) { ret = get(); } function get() view public returns(string memory greeting){ return greeting = "Hello, world!"; } } test1 https://testnet.bscscan.com/tx/0x823f72c8f901eb2b85c011281895a17c9d04d09296941079362e682d0d633209 https://testnet.bscscan.com/tx/0x2a61bd695d17754f8e1a15eb050d86f98874ce026e3ddaec19773a1b4cb50d20 test2 https://testnet.bscscan.com/tx/0x93cd7e582013f0e1f397455665fd54b5c983489a58434a6c5bc732792437b027 https://testnet.bscscan.com/tx/0x1dd8d168baafb8a8b94d50355350432c275ca510ff1846f57e367f9cfe7e39b9 |