kamiweb3-sdk
Version:
TypeScript SDK for KAMI721-C, KAMI721-AC, and KAMI1155-C smart contracts
169 lines (168 loc) • 9.33 kB
TypeScript
import { Contract, BigNumberish, AddressLike, Overrides, ContractTransactionResponse, InterfaceAbi, BytesLike } from 'ethers';
import { RoyaltyData, SignerOrProvider, RoyaltyInfo } from '../types';
/**
* Wraps an instance of the KAMI721AC contract (standard or upgradeable proxy) to provide typed methods.
*/
export declare class ERC721ACWrapper {
readonly contract: Contract;
readonly address: string;
readonly abi: InterfaceAbi;
/**
* Creates an instance of ERC721ACWrapper.
* @param address The address of the standard contract or the proxy contract.
* @param signerOrProvider A Signer (for transactions) or Provider (for read-only).
* @param contractAbi (Optional) The ABI to use. Defaults to the standard KAMI721AC ABI. Provide the KAMI721ACUpgradeable ABI when attaching to a proxy.
*/
constructor(address: AddressLike, signerOrProvider: SignerOrProvider, contractAbi?: InterfaceAbi);
/**
* Returns the number of tokens in `owner`'s account.
* @throws {Error} If owner is the zero address.
*/
balanceOf(owner: AddressLike): Promise<bigint>;
/**
* Returns the owner of the `tokenId` token.
* @throws {Error} If the token does not exist.
*/
ownerOf(tokenId: BigNumberish): Promise<string>;
/**
* Safely transfers `tokenId` token from `from` to `to`.
* @throws {Error} If caller is not owner nor approved, or if `to` is zero address.
*/
safeTransferFrom(from: AddressLike, to: AddressLike, tokenId: BigNumberish, data?: BytesLike, overrides?: Overrides): Promise<ContractTransactionResponse>;
/**
* Transfers `tokenId` token from `from` to `to`.
* Note: Usage of this method is discouraged, use `safeTransferFrom` whenever possible.
* @throws {Error} If caller is not owner nor approved, or if `to` is zero address.
*/
transferFrom(from: AddressLike, to: AddressLike, tokenId: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/**
* Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
* @throws {Error} If `to` is the zero address.
*/
approve(to: AddressLike, tokenId: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/**
* Returns the account approved for `tokenId` token.
* @throws {Error} If the token does not exist.
*/
getApproved(tokenId: BigNumberish): Promise<string>;
/**
* Approve or remove `operator` as an operator for the caller. Operators can call transferFrom or safeTransferFrom for any token owned by the caller.
*/
setApprovalForAll(operator: AddressLike, approved: boolean, overrides?: Overrides): Promise<ContractTransactionResponse>;
/**
* Returns if the `operator` is allowed to manage all of the assets of `owner`.
*/
isApprovedForAll(owner: AddressLike, operator: AddressLike): Promise<boolean>;
/**
* Returns the token collection name.
*/
name(): Promise<string>;
/**
* Returns the token collection symbol.
*/
symbol(): Promise<string>;
/**
* Returns the Uniform Resource Identifier (URI) for `tokenId` token.
* @throws {Error} If the token does not exist.
*/
tokenURI(tokenId: BigNumberish): Promise<string>;
/**
* Returns the total amount of tokens minted in the contract.
* (ERC721A provides this)
*/
totalSupply(): Promise<bigint>;
/**
* Returns the next token ID to be minted.
* (Available in ERC721A-based contracts like KAMI721AC)
*/
nextTokenId(): Promise<bigint>;
/**
* Returns the royalty information for a given token ID and sale price.
* @throws {Error} If token does not exist.
*/
royaltyInfo(tokenId: BigNumberish, salePrice: BigNumberish): Promise<RoyaltyInfo>;
/**
* Mints one or more new NFTs to the caller's address.
* Requires the sender to have approved the contract for the total USDC cost.
* @param quantity The number of NFTs to mint (must be > 0).
* @param overrides Optional transaction overrides.
* @returns A promise that resolves to the transaction response.
*/
mint(quantity: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/**
* Allows users to claim tokens (e.g., airdrop) to the caller's address.
* Requires the sender to have approved the contract for the total USDC cost.
* Assumes claim conditions are handled internally or off-chain.
* @param quantity The number of tokens to claim (must be > 0).
* @param overrides Optional transaction overrides.
* @returns A promise that resolves to the transaction response.
*/
claim(quantity: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/**
* Sells an NFT from the owner (or approved operator) to a buyer.
* Requires seller approval and buyer USDC allowance.
* @throws {Error} If `to` is the zero address.
* @param to The address of the buyer.
* @param tokenId The ID of the token being sold.
* @param salePrice The price in the smallest unit of USDC.
* @param overrides Optional transaction overrides.
* @returns A promise that resolves to the transaction response.
*/
sellToken(to: AddressLike, tokenId: BigNumberish, salePrice: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Sets default mint royalties. Requires OWNER_ROLE. */
setMintRoyalties(royalties: RoyaltyData[], overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Sets default transfer royalties. Requires OWNER_ROLE. */
setTransferRoyalties(royalties: RoyaltyData[], overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Sets token-specific mint royalties. Requires OWNER_ROLE. */
setTokenMintRoyalties(tokenId: BigNumberish, royalties: RoyaltyData[], overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Sets token-specific transfer royalties. Requires OWNER_ROLE. */
setTokenTransferRoyalties(tokenId: BigNumberish, royalties: RoyaltyData[], overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Gets mint royalty receivers for a token. */
getMintRoyaltyReceivers(tokenId: BigNumberish): Promise<RoyaltyData[]>;
/** Gets transfer royalty receivers for a token. */
getTransferRoyaltyReceivers(tokenId: BigNumberish): Promise<RoyaltyData[]>;
/** Sets the mint price. Requires OWNER_ROLE. */
setMintPrice(newMintPrice: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Gets the current mint price. */
getMintPrice(): Promise<bigint>;
/** Sets the platform commission percentage and address. Requires OWNER_ROLE. */
setPlatformCommission(newPercentage: BigNumberish, newPlatformAddress: AddressLike, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Gets the current platform address for commissions. */
getPlatformAddress(): Promise<string>;
/** Gets the current platform commission percentage (basis points). */
getPlatformCommissionPercentage(): Promise<bigint>;
/** Sets the base URI for metadata. Requires OWNER_ROLE. */
setBaseURI(baseURI: string, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Gets the current base URI for metadata. */
getBaseURI(): Promise<string>;
/** Gets the address of the USDC contract used. */
usdc(): Promise<string>;
/** Pauses the contract. Requires PAUSER_ROLE. */
pause(overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Returns true if the contract is paused. */
paused(): Promise<boolean>;
/** Unpauses the contract. Requires PAUSER_ROLE. */
unpause(overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Burns (destroys) a specific token. Requires caller to be owner or approved. */
burn(tokenId: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Checks if an account has a specific role. */
hasRole(role: BytesLike, account: AddressLike): Promise<boolean>;
/** Gets the admin role for a specific role. */
getRoleAdmin(role: BytesLike): Promise<string>;
/** Grants a role to an account. Requires caller to have the admin role for the role being granted. */
grantRole(role: BytesLike, account: AddressLike, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Revokes a role from an account. Requires caller to have the admin role for the role being revoked. */
revokeRole(role: BytesLike, account: AddressLike, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Renounces a role for the caller's own account. */
renounceRole(role: BytesLike, overrides?: Overrides): Promise<ContractTransactionResponse>;
private requireSigner;
private requireRole;
/**
* Connects a different signer or provider to the contract wrapper.
* Preserves the ABI used when the original wrapper was created.
* @param signerOrProvider The new signer or provider.
* @returns A new ERC721ACWrapper instance connected with the new signer/provider.
*/
connect(signerOrProvider: SignerOrProvider): ERC721ACWrapper;
}