Home > Enterprise >  How to test the Solidity-By-Example Mapping smart contract in Remix?
How to test the Solidity-By-Example Mapping smart contract in Remix?

Time:05-23

I want to test the following code in enter image description here

At this point, to test it, I think I need to map an address to a uint256, so I enter the following in the field next to the set button:

["0xcf646ed6e21fd0756ec45a6be5e1057fc24a1b8308175ff0b9f97f565b594eb3", 7439]

The value of the address was a randomly generated hash (I suspect the random hash might be a problem?)

enter image description here

I expect to see the set function render the value 7439. But, instead, it throws the following error:

transact to Mapping.set errored: Error encoding arguments: Error: invalid address (argument="address", value=["0xcf646ed6e21fd0756ec45a6be5e1057fc24a1b8308175ff0b9f97f565b594eb3",7439], code=INVALID_ARGUMENT, version=address/5.5.0) (argument=null, value=["0xcf646ed6e21fd0756ec45a6be5e1057fc24a1b8308175ff0b9f97f565b594eb3",7439], code=INVALID_ARGUMENT, version=abi/5.5.0)

What am I doing wrong?

CodePudding user response:

You have generated a random SHA-256 that is of the format of a valid address, but it doesn't exist on the Remix's browser-based (Javascript VM) chain as any account. If it does, you might be just lucky.

If you want to use valid addresses that do exist on the browser-based VM chain, copy and use the addresses in the account section.

Account section

  • Related