You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.
pragma solidity ^0.5.0;
contract Test {
mapping(uint256 => string) public _storage;
function setStorage() public {
_storage[1] = "test";
}
}
Set a value in the mapping
$ npx oz send-tx
? Pick a network development
? Pick an instance Test at 0xA94B7f0465E98609391C623d0560C5720a3f2D33
? Select which function setStorage()
✓ Transaction successful. Transaction hash: 0x73ea3701929d73e6e0174479ae56f61c98e82109151eda451dff750865795208
Attempt to read the value
Fails as the parameter is not named.
$ npx oz call
? Pick a network development
? Pick an instance Test at 0xA94B7f0465E98609391C623d0560C5720a3f2D33
? Select which function _storage(: uint256)
You must provide a `name` parameter
Read the value specifying method name
We can read the value when we specify a method name and argument.
$ npx oz call --method "_storage(uint256)" --args 1
? Pick a network development
? Pick an instance Test at 0xA94B7f0465E98609391C623d0560C5720a3f2D33
✓ Method '_storage(uint256)' returned: test
test
The text was updated successfully, but these errors were encountered:
Hmm, this probably comes from storage variable getters not requiring a name to their key, since they use it implicitly. Could you check if you can reproduce this issue with the following function?
function getStorage(uint256) publicviewreturns (stringmemory) {
return _storage[1];
}
function getStorage(uint256) public view returns (string memory) {
return _storage[1];
}
Calling the function with a parameter with no name via the interactive commands results in the same error:
$ npx oz call
? Pick a network development
? Pick an instance Test at 0x6f84742680311CEF5ba42bc10A71a4708b4561d1
? Select which function getStorage(: uint256)
You must provide a `name` parameter
The call can be used specifying the method and arguments in the command line.
$ npx oz call --method "getStorage(uint256)" --args 1
? Pick a network development
? Pick an instance Test at 0x6f84742680311CEF5ba42bc10A71a4708b4561d1
✓ Method 'getStorage(uint256)' returned: test
test
oz call
doesn't support reading from public mappingsReported in the forum: https://forum.openzeppelin.com/t/how-to-check-the-mapping-value-via-openzeppelin-cli/1253/2
Test.sol
Set a value in the mapping
Attempt to read the value
Fails as the parameter is not named.
Read the value specifying method name
We can read the value when we specify a method name and argument.
The text was updated successfully, but these errors were encountered: