Skip to content

Instantly share code, notes, and snippets.

@dapplion
Created February 14, 2020 06:47
Show Gist options
  • Save dapplion/31cbfcc22817109855f383c716d1d229 to your computer and use it in GitHub Desktop.
Save dapplion/31cbfcc22817109855f383c716d1d229 to your computer and use it in GitHub Desktop.
Expand original in3 example interacting with contracts but through web3. Extends https://gist.github.com/simon-jentzsch/48fd7a5e9fd59e6d3a0c00815d37d24d
// import in3-Module
const In3Client = require("in3").default;
const Web3 = require("web3");
// use the In3Client as Http-Provider
const web3 = new Web3(
new In3Client({
proof: "standard",
signatureCount: 1,
requestCount: 2,
chainId: "mainnet",
replaceLatestBlock: 50
}).createWeb3Provider()
);
const myTokenContract = "0xdac17f958d2ee523a2206206994597c13d831ec7";
const myAccount = "0x5754284f345afc66a98fbb0a0afe71e0f007b949";
const erc20Abi = [
{
constant: true,
inputs: [{ name: "_owner", type: "address" }],
name: "balanceOf",
outputs: [{ name: "balance", type: "uint256" }],
payable: false,
stateMutability: "view",
type: "function"
}
];
const tokenContract = new web3.eth.Contract(erc20Abi, myTokenContract);
tokenContract.methods
.balanceOf(myAccount)
.call()
.then(balance => console.log("balance:", balance), console.error);
@simon-jentzsch
Copy link

This is an interessting error, since this is what happens:

  1. incubed is updating its nodelist (which worked)
  2. the client is now sending out the eth_call
{"jsonrpc":"2.0","id":1,"method":"eth_call","params":
[{
    "data":"0x70a082310000000000000000000000005754284f345afc66a98fbb0a0afe71e0f007b949",
   "to":"0xdac17f958d2ee523a2206206994597c13d831ec7"
},
"latest"
],"in3":{
  "latestBlock":50,
  "verification":"proofWithSignature",
  "signatures":["0x591761898ba2dfcf3b230bd3ab7d0de0c4ef168f"],
  "version":"2.1.0"
}}

The result looks good, so now we are trying to verify it.

  1. Signature and blockheader is correct
  2. MerkleProofs for all the contracts and storage-values can also be verified
  3. But now we verifiy the result by executing the code in the evm and here I ghet an exception (comming from ethereumjs-vm ) : base fee exceeds gas limit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment