npm package: @matrix-labs/one-sync-sdk
Description: ### ERC721 related APIs
Author: Alvin
Latest version: 1.4.0

# OnceSyncERC721

### ERC721 related APIs

https://docs.openzeppelin.com/contracts/4.x/api/token/erc721#ERC721

```typescript
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
   * @param config
   * @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
   * @param config
   * @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 isLocked - Mint with locked status or not
   * @param nonce
   * @param {string} signature - The signature received from the service
   * @param config
   * @return {Promise<ContractReceipt>} - The contract receipt
   */
  mintWithSignature(
    to: string,
    tokenId: BigNumber,
    isLocked: boolean,
    nonce: string,
    signature: string,
    config?: PayableOverrides
  ): Promise<ContractReceipt>;

  /**
   * Mint batch tokens with the given signature
   *
   * @param {string} to - The address of token recipient
   * @param {Array<BigNumber>} tokenIds - The token id list
   * @param nonce
   * @param isLocked - Mint with locked status or not
   * @param {string} signature - The signature received from the service
   * @param config
   * @return {Promise<ContractReceipt>} - The contract receipt
   */
  mintBatchWithSignature(
    to: string,
    tokenIds: Array<BigNumber>,
    isLocked: boolean,
    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
   * @param config
   * @return {Promise<ContractReceipt>} - The contract receipt
   */
  burn(tokenId: BigNumber, config?: PayableOverrides): Promise<ContractReceipt>;

  /**
   * Burn the token with the given signature
   *
   * @param {Array<BigNumber>} tokenIds - The token id list
   * @param config
   * @return {Promise<ContractReceipt>} - The contract receipt
   */
  burnBatch(tokenIds: Array<BigNumber>, config?: PayableOverrides): Promise<ContractReceipt>;

  /**
   * Burn the token with the given signature
   *
   * @param {Array<BigNumber>} tokenIds - The token id list
   * @param nonce
   * @param {string} signature - The signature received from the service
   * @param config
   * @return {Promise<ContractReceipt>} - The contract receipt
   */
  burnBatchWithSignature(
    tokenIds: Array<BigNumber>,
    nonce: string,
    signature: string,
    config?: PayableOverrides
  ): Promise<ContractReceipt>;
}
```

### Usage:

Browser:

```typescript
// 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]
```