1

在solidity中,我们可以像这样进行结构映射

struct BookEntry {
        string bookId;
        string bookName;
        string authorName;
        bool released;
    }

  mapping (string => BookEntry) keyval;

并像这样设置与 bookId 对应的值

function setBook(string memory bookId, string memory bookName, string memory authorName) public returns(string memory){
   keyval[bookId].bookId = bookId;
   keyval[bookId].bookName = bookName;
   keyval[bookId].authorName = authorName;
   keyval[bookId].released = true;
   return bookId;
}

这种结构如何映射到油墨基材合同中?

#[ink::contract]
mod btc_new {

    use ink_prelude::string::String;

    #[ink(storage)]
    pub struct BookEntry {
        book_id: String,
        book_name: String,
        author_name: String,
        is_released: bool,
        
    }
4

0 回答 0