メインコンテンツまでスキップ

ERC721-Basic

Overview​

It is a library that enables token issuance, operation, and data acquisition that supports ERC721, which is the most distributed NFT (Non-Fungible Token) standard on Ethereum.

Allows you to publish NFTs and register or transfer items to the published NFT Collection.

Install​

npm install @gusdk/erc721-basic

Usage​

import { ERC721Basic, ERC721Basic__factory} from "@gusdk/erc721-basic"
import {BigNumber, ethers, Wallet} from "ethers"

const provider = new ethers.providers.JsonRpcProvider({
url: 'https://sandbox1.japanopenchain.org:8545/'
})

// use the concrete contract factory if you need to operate on the bytecode (ie. deploy)
async function deployTestToken(ownerPK: string): Promise<ERC721Basic> {
const owner = new Wallet(ownerPK, provider);
return new ERC721Basic__factory(owner).deploy(
"TEST123",
"TEST123",
);
}

// to call existing contracts, a factory for both the concrete contract and for the interface
// can be used since the ABI is the same
async function getTokenBalance(walletAddress: string, tokenAddress: string): Promise<BigNumber> {
const token = ERC721Basic__factory.connect(tokenAddress, provider);
return token.balanceOf(walletAddress);
}

Functionality​

name​

name(): Promise<string>;

Returns the name of the token

symbol​

symbol(): Promise<string>;

Returns the symbol of the token

totalSupply​

totalSupply(): Promise<BigNumber>;

Returns the total token supply

balanceOf​

balanceOf(account: PromiseOrValue<string>): Promise<BigNumber>;

Returns the account balance of another account with address account

approve​

approve(to: PromiseOrValue<string>, tokenId: PromiseOrValue<BigNumberish>): Promise<ContractTransaction>;

change or reaffirm the approved address for an NFT

getApproved​

getApproved(tokenId: PromiseOrValue<BigNumberish>): Promise<string>

Get the approved address for a single NFT

isApprovedForAll​

isApprovedForAll(owner: PromiseOrValue<string>, operator: PromiseOrValue<string>): Promise<boolean>;

Query if an address is an authorized operator for another address

ownerOf​

ownerOf(tokenId: PromiseOrValue<BigNumberish>, overrides?: CallOverrides): Promise<string>;

Find the owner of an NFT

safeMint​

safeMint(to: PromiseOrValue<string>, uri: PromiseOrValue<string>): Promise<void>;

Mint a NFT

safeTransferFrom​

"safeTransferFrom(address,address,uint256)"(from: PromiseOrValue<string>, to: PromiseOrValue<string>, tokenId: PromiseOrValue<BigNumberish>): Promise<void>;

or

"safeTransferFrom(address,address,uint256,bytes)"(from: PromiseOrValue<string>, to: PromiseOrValue<string>, tokenId: PromiseOrValue<BigNumberish>, data: PromiseOrValue<BytesLike>): Promise<void>;

Transfers the ownership of an NFT from one address to another address

setApprovalForAll​

setApprovalForAll(operator: PromiseOrValue<string>, approved: PromiseOrValue<boolean>): Promise<void>;

Enable or disable approval for a third party ("operator") to manage

tokenURI​

tokenURI(tokenId: PromiseOrValue<BigNumberish): Promise<string>;

A distinct Uniform Resource Identifier (URI) for a given asset

totalSupply​

totalSupply(): Promise<BigNumber>;

Count NFTs tracked by this contract

transferFrom​

transferFrom(from: PromiseOrValue<string>, to: PromiseOrValue<string>, tokenId: PromiseOrValue<BigNumberish>): Promise<void>;

Transfer ownership of an NFT

transferOwnership​

transferOwnership(newOwner: PromiseOrValue<string>): Promise<void>;

Transfers ownership of the contract to a new account (new owner).Can only be called by the current owner

owner​

owner(): Promise<string>;

Returns the address of the current owner

renounceOwnership​

renounceOwnership(): Promise<void>;

Leaves the contract without owner. It will not be possible to call onlyOwner functions anymore. Can only be called by the current owner

supportsInterface​

supportsInterface(interfaceId: PromiseOrValue<BytesLike>): Promise<boolean>;

function of EIP165

Events​

Transfer​

Transfer(from?: PromiseOrValue<string> | null, to?: PromiseOrValue<string> | null, tokenId?: PromiseOrValue<BigNumberish> | null): TransferEventFilter;

Emitted when tokenId token is transferred from _from to _to.

Approval​

Approval(owner?: PromiseOrValue<string> | null, approved?: PromiseOrValue<string> | null, tokenId?: PromiseOrValue<BigNumberish> | null): ApprovalEventFilter;

Emitted when tokenId token is transferred from _from to _to.

ApprovalForAll​

ApprovalForAll(owner?: PromiseOrValue<string> | null, operator?: PromiseOrValue<string> | null, approved?: null): ApprovalForAllEventFilter;

Emitted when owner enables or disables (approved) operator to manage all of its assets

OwnershipTransferred​

OwnershipTransferred(previousOwner?: PromiseOrValue<string> | null, newOwner?: PromiseOrValue<string> | null): OwnershipTransferredEventFilter;