Update docs
This commit is contained in:
27
docs/modules/api/examples/utilities/Base64NFT.sol
Normal file
27
docs/modules/api/examples/utilities/Base64NFT.sol
Normal file
@ -0,0 +1,27 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
|
||||
import {Strings} from "@openzeppelin/contracts/utils/Strings.sol";
|
||||
import {Base64} from "@openzeppelin/contracts/utils/Base64.sol";
|
||||
|
||||
contract Base64NFT is ERC721 {
|
||||
using Strings for uint256;
|
||||
|
||||
constructor() ERC721("Base64NFT", "MTK") {}
|
||||
|
||||
// ...
|
||||
|
||||
function tokenURI(uint256 tokenId) public pure override returns (string memory) {
|
||||
// Equivalent to:
|
||||
// {
|
||||
// "name": "Base64NFT #1",
|
||||
// // Replace with extra ERC-721 Metadata properties
|
||||
// }
|
||||
// prettier-ignore
|
||||
string memory dataURI = string.concat("{\"name\": \"Base64NFT #", tokenId.toString(), "\"}");
|
||||
|
||||
return string.concat("data:application/json;base64,", Base64.encode(bytes(dataURI)));
|
||||
}
|
||||
}
|
||||
15
docs/modules/api/examples/utilities/Multicall.sol
Normal file
15
docs/modules/api/examples/utilities/Multicall.sol
Normal file
@ -0,0 +1,15 @@
|
||||
// contracts/Box.sol
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {Multicall} from "@openzeppelin/contracts/utils/Multicall.sol";
|
||||
|
||||
contract Box is Multicall {
|
||||
function foo() public {
|
||||
// ...
|
||||
}
|
||||
|
||||
function bar() public {
|
||||
// ...
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user