Last active
August 25, 2022 01:45
-
-
Save gwmccubbin/f47c414760f7f3791f00775a6f1d2108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.6.0; | |
contract MyContract { | |
// Mappings | |
mapping(uint => string) public names; | |
mapping(uint => Book) public books; | |
mapping(address => mapping(uint => Book)) public myBooks; | |
struct Book { | |
string title; | |
string author; | |
} | |
constructor() public { | |
names[1] = "Adam"; | |
names[2] = "Bruce"; | |
names[3] = "Carl"; | |
} | |
function addBook(uint _id, string memory _title, string memory _author) public { | |
books[_id] = Book(_title, _author); | |
} | |
function addMyBook(uint _id, string memory _title, string memory _author) public { | |
myBooks[msg.sender][_id] = Book(_title, _author); | |
} | |
} |
Hi Greg, Why am I facing such error when I add book. It shows this error. What I need to do about it?
transact to MyContract.addBook errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="MyBook", code=INVALID_ARGUMENT, version=bignumber/5.5.0)
Hi Greg, Why am I facing such error when I add book. It shows this error. What I need to do about it?
transact to MyContract.addBook errored: Error encoding arguments: Error: invalid BigNumber string (argument="value", value="MyBook", code=INVALID_ARGUMENT, version=bignumber/5.5.0)
Change the first line version code with "pragma solidity >=0.4.16 <0.9.0;" .. It should work
Found this very helpful. Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is very cool. So what if I want to get all books under a particular sender? like a getSendersBooks function? How will that look like? Thank you.