Skip to content

Commit

Permalink
add sbt
Browse files Browse the repository at this point in the history
  • Loading branch information
akihokurino committed Feb 12, 2023
1 parent e378030 commit bb40b19
Show file tree
Hide file tree
Showing 23 changed files with 4,180 additions and 25,425 deletions.
1 change: 1 addition & 0 deletions .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ WALLET_SECRET=
ETHEREUM_RUST_TOKEN_721_ADDRESS=0xb45788Bf46F1189C66a008dAb10c2f526c3fB87c
ETHEREUM_RUST_TOKEN_1155_ADDRESS=0xF239EeE3a78eC18ABBB78E9b5E46758019EE5d81
ETHEREUM_REVEAL_TOKEN_721_ADDRESS=0xeEB73DDA4454B497Eb51325983f56006735aB702
ETHEREUM_RUST_SBT_721_ADDRESS=0xaed49FB5f830001505d489a75474c7E7372b0E81

POLYGON_RUST_TOKEN_721_ADDRESS=0x58bBe70EF8239B9d09F10a70F0FF291DFD70f8Df
POLYGON_RUST_TOKEN_1155_ADDRESS=0x46005CbED485e6BFbE3F7Dc50D8BE5553Af989e1
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,6 @@ extract-abi:
cat ethereum/artifacts/contracts/RustToken721.sol/RustToken721.json | jq -r '.bytecode' > src/ethereum/ethers_rs/rust-token721.bin
cat ethereum/artifacts/contracts/RustToken1155.sol/RustToken1155.json | jq -r '.bytecode' > src/ethereum/ethers_rs/rust-token1155.bin
cat ethereum/artifacts/contracts/RevealToken721.sol/RevealToken721.json | jq '.abi' > src/ethereum/ethers_rs/reveal-token721.abi.json
cat ethereum/artifacts/contracts/RevealToken721.sol/RevealToken721.json | jq '.bytecode' > src/ethereum/ethers_rs/reveal-token721.bin
cat ethereum/artifacts/contracts/RevealToken721.sol/RevealToken721.json | jq '.bytecode' > src/ethereum/ethers_rs/reveal-token721.bin
cat ethereum/artifacts/contracts/RustSbt721.sol/RustSbt721.json | jq '.abi' > src/ethereum/ethers_rs/rust-sbt721.abi.json
cat ethereum/artifacts/contracts/RustSbt721.sol/RustSbt721.json | jq '.bytecode' > src/ethereum/ethers_rs/rust-sbt721.bin
Binary file modified asset/sample.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 18 additions & 8 deletions ethereum/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,34 @@ node:
npx hardhat node

deploy-hardhat:
npx hardhat run scripts/deploy-tokens.ts --network hardhat
npx hardhat run scripts/deploy-nft.ts --network hardhat
npx hardhat run scripts/deploy-oracle.ts --network hardhat
npx hardhat run scripts/deploy-reveal-token.ts --network hardhat
npx hardhat run scripts/deploy-sbt.ts --network hardhat

deploy-geth:
npx hardhat run scripts/deploy-tokens.ts --network geth
npx hardhat run scripts/deploy-nft.ts --network geth
npx hardhat run scripts/deploy-oracle.ts --network geth
npx hardhat run scripts/deploy-reveal-token.ts --network geth
npx hardhat run scripts/deploy-sbt.ts --network geth

deploy-tokens-goerli:
npx hardhat run scripts/deploy-tokens.ts --network goerli
deploy-nft-goerli:
npx hardhat run scripts/deploy-nft.ts --network goerli

deploy-oracle-goerli:
npx hardhat run scripts/deploy-oracle.ts --network goerli

deploy-tokens-mumbai:
npx hardhat run scripts/deploy-tokens.ts --network mumbai
deploy-reveal-token-goerli:
npx hardhat run scripts/deploy-reveal-token.ts --network goerli

deploy-tokens-fuji:
npx hardhat run scripts/deploy-tokens.ts --network fuji
deploy-sbt-goerli:
npx hardhat run scripts/deploy-sbt.ts --network goerli

deploy-nft-mumbai:
npx hardhat run scripts/deploy-nft.ts --network mumbai

deploy-nft-fuji:
npx hardhat run scripts/deploy-nft.ts --network fuji

init-private-net:
geth --datadir ./private-net/ init ./private-net/genesis.json
Expand Down
61 changes: 61 additions & 0 deletions ethereum/contracts/RustSbt721.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";

contract RustSbt721 is ERC721Upgradeable, OwnableUpgradeable {
mapping(uint256 => string) private _token2hash;
uint256 private _localTokenId;
string private _baseUrl;

function initialize(string memory name, string memory symbol)
public
initializer
{
__ERC721_init(name, symbol);
__Ownable_init();
_localTokenId = 0;
_baseUrl = "https://akiho-playground.infura-ipfs.io/ipfs/";
}

function mint(string memory contentHash) public virtual onlyOwner {
_localTokenId += 1;
_token2hash[_localTokenId] = contentHash;
_mint(_msgSender(), _localTokenId);
}

function setBaseURI(string memory base) public virtual onlyOwner {
_baseUrl = base;
}

function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
string memory contentHash = _token2hash[tokenId];
return string(abi.encodePacked(_baseUrl, contentHash));
}

function isOwner(uint256 tokenId, address target)
public
view
virtual
returns (bool)
{
return ownerOf(tokenId) == target;
}

function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId,
uint256 batchSize
) internal override {
require(from == address(0), "Err: token is SOUL BOUND");
super._beforeTokenTransfer(from, to, tokenId, batchSize);
}
}
2 changes: 1 addition & 1 deletion ethereum/hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "@nomicfoundation/hardhat-chai-matchers";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@openzeppelin/hardhat-upgrades";
import dotenv from "dotenv";
import { HardhatUserConfig } from "hardhat/config";
Expand Down
Loading

0 comments on commit bb40b19

Please sign in to comment.