DeveryERC721

DeveryERC721

Main class to deal with the owned smart contract interface and related operations, you can use it to check the current contract owner and listen to ownership change related events

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) 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 product 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 being transferred

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(ownerAddres, productAddres)

This method return you wether a account owns tokens of a determined 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(ownerAddres, productAddres)
 .then(hasProduct => console.log(hasProduct))
 .catch(err => {
   //treat errors
 })
Parameters:
Name Type Description
ownerAddres string

Blockchain address of the inspect account

productAddres string

Blockchain addres of the checked product

Source:

getSignerAddress() → {*}

You can use this method to check the current signer wallet address.

Inherited From:
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.

Inherited From:
Source: