Skip to content

How to get the values from an array? #3783

Discussion options

You must be logged in to vote

This works for me:

async function getGreeting(vm: VM, contractAddress: Address, caller: Address) {
  const sigHash = new Interface(['function arr(uint256)']).getFunction('arr')!.selector

  // Encode the parameter
  const encodedParams = new AbiCoder().encode(['uint256'], [0])

  // Combine sigHash with encoded parameters
  const data = hexToBytes(sigHash + encodedParams.slice(2))

  const greetResult = await vm.evm.runCall({
    to: contractAddress,
    caller,
    origin: caller, // The tx.origin is also the caller here
    data,
    block,
  })

  if (greetResult.execResult.exceptionError) {
    throw greetResult.execResult.exceptionError
  }

  const results = new AbiCoder().decode(['…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@andreachello
Comment options

@andreachello
Comment options

@jochem-brouwer
Comment options

Answer selected by andreachello
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants