Skip to content

Instantly share code, notes, and snippets.

@Sankalpks
Created January 6, 2022 06:49
Show Gist options
  • Save Sankalpks/a285f9cd9616d5a547624fb7e26c7c0c to your computer and use it in GitHub Desktop.
Save Sankalpks/a285f9cd9616d5a547624fb7e26c7c0c to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=builtin&optimize=false&runs=200&gist=
pragma solidity ^0.6.0;
contract MyContract{
mapping(uint=>Book) public books;
mapping(address=> mapping(uint=>Book)) public mybooks;
struct Book{
string Title;
string Author;
}
function addbook(uint _id,string memory _Title, string memory _Author) public {
books[_id]= Book(_Title, _Author);
}
function addmybooksid(uint _id,string memory _Title, string memory _Author) public {
mybooks[msg.sender][_id]= Book(_Title, _Author);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment