@white-matrix/one-sync-sdk
v1.0.0
Published
### ERC721 related APIs
Downloads
12
Keywords
Readme
OnceSyncERC721_v1_1_1
ERC721 related APIs
https://docs.openzeppelin.com/contracts/4.x/api/token/erc721#ERC721
export interface OneSyncERC721Client extends ERC721Client {
connectProvider(
address: string,
provider: Provider
): Promise<OneSyncERC721Client>;
connectSigner(signer: Signer): OneSyncERC721Client;
setWaitConfirmations(num: number): void;
/**
* Get the owner/admin of the token
*
* @param {CallOverrides} [config] - Override the default contract call config
* @return {Promise<string>} - The owner of the collection
*/
owner(config?: CallOverrides): Promise<string>;
/**
* Get contract implementation version
*
* @param {CallOverrides} [config] - Override the default contract call config
* @return {Promise<string>} - The contract implementation version
*/
implementationVersion(config?: CallOverrides): Promise<string>;
/**
* Get latest token Version (tokenVersion + 1 after unlock and lock)
*
* @param {BigNumber} tokenId - The token id
* @param {CallOverrides} [config] - Override the default contract call config
* @return {Promise<string>} - The contract implementation version
*/
tokenVersion(tokenId: BigNumber, config?: CallOverrides): Promise<BigNumber>;
/**
* Check if the token is locked
*
* @param {BigNumber} tokenId - The token id
* @param {CallOverrides} [config] - Override the default contract call config
* @return {Promise<string>} - The contract implementation version
*/
locked(tokenId: BigNumber, config?: CallOverrides): Promise<boolean>;
/**
* Lock the token
*
* @param {BigNumber} tokenId - The token id
* @return {Promise<ContractReceipt>} - The contract receipt
*/
lock(tokenId: BigNumber, config?: PayableOverrides): Promise<ContractReceipt>;
/**
* Unlock the token
*
* @param {BigNumber} tokenId - The token id
* @param {BigNumber} version - The current version of the token
* @param {string} signature - The signature of the transaction
* @return {Promise<ContractReceipt>} - The contract receipt
*/
unLock(
tokenId: BigNumber,
version: BigNumber,
signature: string,
config?: PayableOverrides
): Promise<ContractReceipt>;
/**
* Mint token with the given signature
*
* @param {string} to - The address of token recipient
* @param {BigNumber} tokenId - The token id
* @param {BigNumber} version - The current version of the token
* @param {string} signature - The signature received from the service
* @return {Promise<ContractReceipt>} - The contract receipt
*/
mintWithSignature(
to: string,
tokenId: BigNumber,
nonce: string,
signature: string,
config?: PayableOverrides
): Promise<ContractReceipt>;
/**
* Burn the token
* NOTICE: the token should not at the status of locked
*
* @param {BigNumber} tokenId - The token id
* @return {Promise<ContractReceipt>} - The contract receipt
*/
burn(tokenId: BigNumber, config?: PayableOverrides): Promise<ContractReceipt>;
}
Usage:
Browser:
// setup client
const web3Provider = new ethers.providers.Web3Provider(window.ethereum);
await web3Provider.current.send('eth_requestAccounts', []);
const signer = ethProvider.current.getSigner();
const contractAddress = '0x......';
const nftClient = EtherOneSyncERC721Client();
await nftClient.connectProvider(contractAddress, web3Provider);
nftClient.connectSigner(signer);
nftClient.setWaitConfirmations(1); // 1 for testnet, 5 for mainnet
// const result = await nftClient.[ERC721 + OnceSync APIs]