Update docs
This commit is contained in:
21
docs/modules/api/examples/token/ERC1155/GameItems.sol
Normal file
21
docs/modules/api/examples/token/ERC1155/GameItems.sol
Normal file
@ -0,0 +1,21 @@
|
||||
// contracts/GameItems.sol
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {ERC1155} from "@openzeppelin/contracts/token/ERC1155/ERC1155.sol";
|
||||
|
||||
contract GameItems is ERC1155 {
|
||||
uint256 public constant GOLD = 0;
|
||||
uint256 public constant SILVER = 1;
|
||||
uint256 public constant THORS_HAMMER = 2;
|
||||
uint256 public constant SWORD = 3;
|
||||
uint256 public constant SHIELD = 4;
|
||||
|
||||
constructor() ERC1155("https://game.example/api/item/{id}.json") {
|
||||
_mint(msg.sender, GOLD, 10 ** 18, "");
|
||||
_mint(msg.sender, SILVER, 10 ** 27, "");
|
||||
_mint(msg.sender, THORS_HAMMER, 1, "");
|
||||
_mint(msg.sender, SWORD, 10 ** 9, "");
|
||||
_mint(msg.sender, SHIELD, 10 ** 9, "");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,7 @@
|
||||
// contracts/MyERC115HolderContract.sol
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {ERC1155Holder} from "@openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol";
|
||||
|
||||
contract MyERC115HolderContract is ERC1155Holder {}
|
||||
11
docs/modules/api/examples/token/ERC20/GLDToken.sol
Normal file
11
docs/modules/api/examples/token/ERC20/GLDToken.sol
Normal file
@ -0,0 +1,11 @@
|
||||
// contracts/GLDToken.sol
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
|
||||
|
||||
contract GLDToken is ERC20 {
|
||||
constructor(uint256 initialSupply) ERC20("Gold", "GLD") {
|
||||
_mint(msg.sender, initialSupply);
|
||||
}
|
||||
}
|
||||
19
docs/modules/api/examples/token/ERC721/GameItem.sol
Normal file
19
docs/modules/api/examples/token/ERC721/GameItem.sol
Normal file
@ -0,0 +1,19 @@
|
||||
// contracts/GameItem.sol
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity ^0.8.20;
|
||||
|
||||
import {ERC721URIStorage, ERC721} from "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
|
||||
|
||||
contract GameItem is ERC721URIStorage {
|
||||
uint256 private _nextTokenId;
|
||||
|
||||
constructor() ERC721("GameItem", "ITM") {}
|
||||
|
||||
function awardItem(address player, string memory tokenURI) public returns (uint256) {
|
||||
uint256 tokenId = _nextTokenId++;
|
||||
_mint(player, tokenId);
|
||||
_setTokenURI(tokenId, tokenURI);
|
||||
|
||||
return tokenId;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user