Constructor
new DeveryERC721(options)
Creates a new instansce of DeveryERC721.
// creates a DeveryERC721Client with the default params
let deveryERC721Client = new DeveryERC721();
//creates a deveryRegistryClient pointing to a custom address
let deveryERC721Client = new DeveryERC721({address:'0xf17f52151EbEF6C7334FAD080c5704DAAA16b732'});
Parameters:
Name | Type | Description |
---|---|---|
options |
ClientOptions |
network connection options |
- Version:
-
- 1
- Source:
Extends
Methods
(async) claimProduct(productAddress, quantity, overrideOptionsopt)
This method is used for claiming a product. The method returns you the transaction address of the claim. If the product have a maximum mintable quantity set and you try to claim a number of product bigger than the mintable products number set the method will not work
Usage example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
// Let's log the simplest case of use in the console
deveryErc721Client.claimProduct('0x627306090abaB3A6e1400e9345bC60c78a8BEf57', 1).then(response =>
console.log('response').catch(err => {
// treat you error
})
)
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
productAddress |
string |
address of the claimed product |
||
quantity |
number | 1 |
quantity of claimed products |
|
overrideOptions |
TransactionOptions |
<optional> |
gas options to override the default ones. |
- Source:
(async) estimateClaimProduct(productAddress, quantity, overrideOptionsopt)
This method gives an estimation of how much gas will be used for the method DeveryERC721.claimProduct the params that you pass to this method shall be exactly the same ones that you would pass to DeveryERC721.claimProduct. the return of this method will be the total gas used to call DeveryERC721.claimProduct with the given parameters
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
productAddress |
string |
address of the claimed product |
||
quantity |
number | 1 |
quantity of claimed products |
|
overrideOptions |
TransactionOptions |
<optional> |
gas options to override the default ones. |
- Source:
(async) getApproved(address, overrideOptionsopt)
This method returns you the total amount of approved transactions of the inspected product (referenced by it's token).
Usage example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
// Let's log the simplest case of use in the console
deveryErc721Client.getApproved(address).then(response => console.log(`Number of approved transactions ${response}`))
//response is going to be an hexadecimal number representing the amount of approved transactions made with it
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
address |
string |
token address to be inspected. |
|
overrideOptions |
TransactionOptions |
<optional> |
gas options to override the default ones. |
- Source:
(async) getProductsByOwner(addressOwner, overrideOptionsopt)
Each brand has a blockchain address. This function returns an array with all the product addresses owned by the address passed as a parameter.
Usage example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
// Let's log the simplest case of use in the console.
deveryErc721Client.getProductsByOwner(addressOwner).then(response => console.log('these are the products owned by this address', response))
// Since this is a promise function you will need a .then statement to display the result
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
addressOwner |
string |
the blockchain address of whom we want to know the owned tokens |
|
overrideOptions |
TransactionOptions |
<optional> |
gas options to override the default ones |
- Source:
setApprovalEventListener(callback)
Listener for transfer approval events, this event triggers whenever a devery item is transferred in the blockchain. Please note that ApprovalEventListeners do not stack, this means that whenever you set one you are removing the last one. If you want to remove an ApprovalEventListener, just call this function passing undefined as param.
Usage example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
deveryErc721Client.setApprovalEventListener((brandAccount,appAccount,active) => {
// whenever an app created we will log it to the console
console.log(`a brand has been updated ${brandAccount} - ${appAccount} ...`);
})
// if you want to remove the listener you can simply pass undefined as parameter
deveryErc721Client.setApprovalEventListener(undefined)
// or that is equivalent to the above call
deveryErc721Client.setApprovalEventListener()
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Description |
---|---|---|
callback |
ApprovalEventCallback |
the callback that will be executed whenever an ApprovalForAll event is triggered |
- Source:
setApprovalForAllEventListener(callback)
Listener for transfer approval for all events, this event triggers whenever a devery item is transferred in the blockchain. Please note that ApprovalForAllEventListeners do not stack, this means that whenever you set one you are removing the last one. If you want to remove an ApprovalForAllEventListener, just call this function passing undefined as param.
Usage example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
deveryErc721Client.setApprovalForAllEventListener((brandAccount,appAccount,active) => {
// whenever an app created we will log it to the console
console.log(`a brand has been updated ${brandAccount} - ${appAccount} ...`);
})
// if you want to remove the listener you can simply pass undefined as parameter
deveryRegistryClient.setApprovalForAllEventListener(undefined)
// or that is equivalent to the above call
deveryRegistryClient.setApprovalForAllEventListener()
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Description |
---|---|---|
callback |
ApprovalEventCallback |
the callback that will be executed whenever a Approval event is triggered |
- Source:
setTransferEventListener(callback)
Listener for transfer events, this event triggers whenever a devery item is transferred in the blockchain. Please note that TransferEventListeners do not stack, this means that whenever you set one you are removing the last one. If you want to remove a TransferEventListener, just call this function passing undefined as param.
Usage example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
deveryErc721Client.setTransferEventListener((brandAccount,appAccount,active) => {
// whenever an app created we will log it to the console
console.log(`a brand has been updated ${brandAccount} - ${appAccount} ...`);
})
// if you want to remove the listener you can simply pass undefined as parameter
deveryErc721Client.setTransferEventListener(undefined)
// or that is equivalent to the above call
deveryErc721Client.setTransferEventListener()
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Description |
---|---|---|
callback |
ApprovalEventCallback |
the callback that will be executed whenever a Transfer event is triggered |
- Source:
(async) setMaximumMintableQuantity(productAddress, quantity, overrideOptionsopt) → {Promise.<Transaction>}
Sets the maximum mintable quantity of a given token. *** If you don't set the maximum mintable quantity it will be infinite by default**
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
productAddress |
string |
The address of the product which the mintable quantity will be set. |
|
quantity |
string |
the allowed quantity of mintable products. |
|
overrideOptions |
TransactionOptions |
<optional> |
gas options to override the default ones |
- Source:
(async) tokenIdToProduct(tokenId) → {Promise.<String>}
This method returns the blockchain address of a product, using its token as a parameter.
Usage Example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
// to use this function you need to have a token, which can be get through a function like tokenOfOwnerByIndex
// The token is a hexadecimal number
deveryErc721Client.tokenIdToProduct(tokenId).then(response => console.log('this is your product address', response))
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Description |
---|---|---|
tokenId |
string |
The token of the product you wish to get the address of. |
- Source:
(async) balanceOf(ownerAddress, overrideOptionsopt) → {Promise.<*>}
This method returns the (hexadecimal) number of products owned by the account address passed as parameter to the function.
Usage Example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
// this method requires an owner address, which can be obtained on the metamask extension by clicking on your account name
deveryErc721Client.__deveryERC721Contract.balanceOf(ownerAddress).then(response => console.log('this account owns number of products: ', response))
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ownerAddress |
string |
Blockchain address of the inspected account. |
|
overrideOptions |
TransactionOptions |
<optional> |
gas options to override the default ones. |
- Source:
(async) tokenOfOwnerByIndex(ownerAddress, index, overrideOptionsopt) → {Promise.<*>}
This method returns the token of a product by its index (it's a position in an array containing all the products owned by the owner address).
Usage Example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
deveryErc721Client.__deveryERC721Contract.tokenOfOwnerByIndex(ownerAddress, index).then(response => ( console.log('product token', response)))
// the product order is the same as the array returned by getProductByOwner() . Wherefore the index 0 it's the first address returned by the getProductByOwner method,
// the index 1 is the second address and so on.
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ownerAddress |
string |
blockchain address of that we want to know the owned tokens. |
|
index |
number |
position of the product in the array of all products owned by the account corresponding to the address. |
|
overrideOptions |
TransactionOptions |
<optional> |
gas options to override the default ones |
- Source:
(async) totalAllowedProducts(productAddress) → {Promise.<Number>}
This method allows you to query the number of tokens linked to the product address, representing the amount of that product generated. The response is returned as a hexadecimal number.
Usage example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
deveryErc721Client.totalAllowedProducts(productAddress).then(response => {
console.log(`this is the total amount of products Allowed ${response}`)
}).catch(err => {
// handle exceptions here
})
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Description |
---|---|---|
productAddress |
string |
Blockchain address of the product. |
- Source:
(async) totalMintedProducts(productAddress) → {Promise.<Number>}
You can generate a limited amount of products for each product address. If you try to generated more products than you are allowed, this product is going to be minted. This method returns you the number of minted products for a specific product address.
Usage Example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
deveryErc721Client.totalMintedProducts(productAddress).then(response =>
(console.log('you have the following number of minted products for this address ', response)))
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Description |
---|---|---|
productAddress |
string |
inspected product address. |
- Source:
(async) safeTransferFrom(fromAddress, toAddress, tokenId)
This method transfers the ownership of a claimed product item from one account to another. The transfer must be made logged in the account referenced in the 'fromAddress' parameter, otherwise the transfer will be denied.
*** Usage Example: ***
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// now you can use it
deveryErc721Client.safeTransferFrom(fromAddress, toAddress, tokenId).then(transaction => {
console.log('your transaction was successful');
// other stuff
}).catch(err => {
if(err.message.indexOf('gas required exceeds allowance or always failing transaction') {
console.log('You do not own the product you are trying to transfer')}
})
for more info about how to get a DeveryERC721 instance click here.
Parameters:
Name | Type | Description |
---|---|---|
fromAddress |
string |
blockchain address which the transfer is coming from |
toAddress |
string |
blockchain address which the transfer is going to |
tokenId |
string |
Token of the product item being transferred or blockchain address of the product account. In case if product address was specified then for transfer is taken the first token (product item) of the specified product owned by the fromAddress account. |
- Source:
(async) setDeveryRegistryAddress(deveryRegistryContractAddress, overrideOptionsopt)
This method creates a devery registry address for the desired contract, so the user is able to properly use the devery ERC721 methods.
Usage example:
// first you need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
//n ow you can use it
// then you have to pass the devery contract method passing the contract as a parameter
deveryErc721Client.setDeveryRegistryAddress(address).then(transaction => {
console.log(transaction) }).catch(err => {
// treat your errors here
})
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
deveryRegistryContractAddress |
string |
address of the deployed contract. |
|
overrideOptions |
TransactionOptions |
<optional> |
gas options to override the default ones. |
- Source:
(async) hasAccountClaimendProduct(ownerAddress, productAddress)
This method returns you whether the account owns tokens of the specified product or not. The return of this function is a boolean value.
Usage Example
// First you'll need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// Then you will need to pass an account address and a product address as parameters
deveryErc721Client.hasAccountClaimendProduct(ownerAddress, productAddress)
.then(hasProduct => console.log(hasProduct))
.catch(err => {
//treat errors
})
Parameters:
Name | Type | Description |
---|---|---|
ownerAddress |
string |
Blockchain address of the inspect account |
productAddress |
string |
Blockchain address of the checked product |
- Source:
(async) setTokenURI(tokenId, tokenUri)
This methods sets the metadata URI for a given token, this URI can be any valid URI in the internet and is expected to contain a metadata file with info about the token. this file is expected to be a valid json file. bellow you can see an example of such file
IMPORTANT: only the address that owns a NFT can set it's metadata URI
it's important to remember that it's client`s responsability to host and ensure that the URI points to a valid metadata file
{
"name": "Imaginary product",
"description": "This describes our imaginary product and how it behaves",
"image": "https://markery.io/img/markery-io-logo.svg",
}```
this is not an extensive example and you can add more data to suite your own use cases
***Usage Example***
// First you'll need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// then you have to pass the devery contract method passing the contract as a parameter deveryErc721Client.setTokenURI(tokenId,address).then(transaction => { console.log(transaction) }).catch(err => { // treat your errors here })
Parameters:
Name | Type | Description |
---|---|---|
tokenId |
string |
Token for which the uri will be set |
tokenUri |
string |
URI for the token |
- Source:
(async) tokenURI(tokenId)
returns the URI containing metadata for a given token, if there's no such URI for the given token an empty string will be returned
Usage Example
// First you'll need to get a DeveryERC721 instance
let deveryErc721Client = new DeveryERC721();
// then you have to pass the devery contract method passing the contract as a parameter
deveryErc721Client.tokenURI(tokenId).then(address => {
console.log(address) }).catch(err => {
// treat your errors here
})
Parameters:
Name | Type | Description |
---|---|---|
tokenId |
string |
Token for which the uri will be retrieved |
- Source:
getSignerAddress() → {*}
You can use this method to check the current signer wallet address.
- Overrides:
- Source:
getProvider() → {*}
Returns the internal signer or provider, this method needs to be used with caution as it exposes internals. So unless you know what you are doing it's better to avoid using it.
- Overrides:
- Source: