kamiweb3-sdk
Version:
TypeScript SDK for KAMI721-C, KAMI721-AC, and KAMI1155-C smart contracts
177 lines (176 loc) • 9.9 kB
TypeScript
import { Contract, BigNumberish, AddressLike, Overrides, ContractTransactionResponse, InterfaceAbi, BytesLike } from 'ethers';
import { RoyaltyData, SignerOrProvider, RentalDetails, RoyaltyInfo } from '../types';
/**
* Wraps an instance of the ERC721C contract (standard or upgradeable proxy) to provide typed methods.
*/
export declare class ERC721CWrapper {
readonly contract: Contract;
readonly address: string;
readonly abi: InterfaceAbi;
/**
* Creates an instance of ERC721CWrapper.
* @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 KAMI721C ABI. Provide the KAMI721CUpgradeable 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.
*/
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 stored by the contract.
*/
totalSupply(): Promise<bigint>;
/**
* Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
* @throws {Error} If `index` >= `balanceOf(owner)` or `owner` is zero address.
*/
tokenOfOwnerByIndex(owner: AddressLike, index: BigNumberish): Promise<bigint>;
/**
* Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
* @throws {Error} If `index` >= `totalSupply()`.
*/
tokenByIndex(index: BigNumberish): 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 a single new NFT to the caller's address.
* Requires the sender to have approved the contract for the USDC mint cost.
* @param overrides Optional transaction overrides.
* @returns A promise that resolves to the transaction response.
*/
mint(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>;
/** Rents a token for a specified duration. Requires renter USDC allowance. */
rentToken(tokenId: BigNumberish, duration: BigNumberish, rentalPrice: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Ends a rental period early. Callable by owner or renter (verify contract logic). */
endRental(tokenId: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Extends an existing rental. Requires renter USDC allowance for additional payment. */
extendRental(tokenId: BigNumberish, additionalDuration: BigNumberish, additionalPayment: BigNumberish, overrides?: Overrides): Promise<ContractTransactionResponse>;
/** Gets the rental details for a specific token ID. */
getRentalDetails(tokenId: BigNumberish): Promise<RentalDetails>;
/** 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 the transfer royalty configuration for a specific token ID.
*/
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 all token IDs. Requires OWNER_ROLE. */
setBaseURI(baseURI: string, overrides?: Overrides): Promise<ContractTransactionResponse>;
/**
* Gets the base URI.
*/
getBaseURI(): Promise<string>;
/** Gets the address of the USDC contract used for payments. */
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 ERC721CWrapper instance connected with the new signer/provider.
*/
connect(signerOrProvider: SignerOrProvider): ERC721CWrapper;
}