// call any function in your contract awaitcontract.call("myCustomFunction", [param1, param2]);
// if your contract follows the ERC721 standard, contract.nft will be present constallNFTs = awaitcontract.erc721.query.all()
// if your contract extends IMintableERC721, contract.nft.mint() will be available consttx = awaitcontract.erc721.mint({ name:"Cool NFT", image:readFileSync("some_image.png"), });
// Predict the address of the account that will be created for an admin. constdeterministicAddress = awaitcontract.accountFactory.predictAccountAddress(admin, extraData);
// Create accounts consttx = awaitcontract.accountFactory.createAccount(admin, extraData); // the same as `deterministicAddress` constaccountAddress = tx.address;
// Get all accounts created by the factory constallAccounts = awaitcontract.accountFactory.getAllAccounts();
// Get all accounts on which a signer has been given authority. constassociatedAccounts = awaitcontract.accountFactory.getAssociatedAccounts(signer);
// Get all signers who have been given authority on a account. constassociatedSigners = awaitcontract.accountFactory.getAssociatedSigners(accountAddress);
// Check whether a account has already been created for a given admin. constisAccountDeployed = awaitcontract.accountFactory.isAccountDeployed(admin, extraData);
Create and manage direct listings in your marketplace.
// Data of the listing you want to create constlisting = { // address of the contract the asset you want to list is on assetContractAddress:"0x...", // token ID of the asset you want to list tokenId:"0", // how many of the asset you want to list quantity:1, // address of the currency contract that will be used to pay for the listing currencyContractAddress:NATIVE_TOKEN_ADDRESS, // The price to pay per unit of NFTs listed. pricePerToken:1.5, // when should the listing open up for offers startTimestamp:newDate(Date.now()), // how long the listing will be open for endTimestamp:newDate(Date.now() + 5 * 24 * 60 * 60 * 1000), // Whether the listing is reserved for a specific set of buyers. isReservedListing:false }
consttx = awaitcontract.directListings.createListing(listing); constreceipt = tx.receipt; // the transaction receipt constid = tx.id; // the id of the newly created listing
// And on the buyers side: // The ID of the listing you want to buy from constlistingId = 0; // Quantity of the asset you want to buy constquantityDesired = 1;
// Data of the auction you want to create constauction = { // address of the contract of the asset you want to auction assetContractAddress:"0x...", // token ID of the asset you want to auction tokenId:"0", // how many of the asset you want to auction quantity:1, // address of the currency contract that will be used to pay for the auctioned tokens currencyContractAddress:NATIVE_TOKEN_ADDRESS, // the minimum bid that will be accepted for the token minimumBidAmount:"1.5", // how much people would have to bid to instantly buy the asset buyoutBidAmount:"10", // If a bid is made less than these many seconds before expiration, the expiration time is increased by this. timeBufferInSeconds:"1000", // A bid must be at least this much bps greater than the current winning bid bidBufferBps:"100", // 100 bps stands for 1% // when should the auction open up for bidding startTimestamp:newDate(Date.now()), // end time of auction endTimestamp:newDate(Date.now() + 5 * 24 * 60 * 60 * 1000), }
consttx = awaitcontract.englishAuctions.createAuction(auction); constreceipt = tx.receipt; // the transaction receipt constid = tx.id; // the id of the newly created auction
// And on the buyers side: // The auction ID of the asset you want to bid on constauctionId = 0; // The total amount you are willing to bid for auctioned tokens constbidAmount = 1;
// Data of the offer you want to make constoffer = { // address of the contract the asset you want to make an offer for assetContractAddress:"0x...", // token ID of the asset you want to buy tokenId:"0", // how many of the asset you want to buy quantity:1, // address of the currency contract that you offer to pay in currencyContractAddress:NATIVE_TOKEN_ADDRESS, // Total price you offer to pay for the mentioned token(s) totalPrice:"1.5", // Offer valid until endTimestamp:newDate(), }
consttx = awaitcontract.offers.makeOffer(offer); constreceipt = tx.receipt; // the transaction receipt constid = tx.id; // the id of the newly created offer
// And on the seller's side: // The ID of the offer you want to accept constofferId = 0; awaitcontract.offers.acceptOffer(offerId);
Custom contract dynamic class with feature detection
Example