Non-Provider Methods

These methods interact with Cargo via HTTPS and do not require an Ethereum provider such as MetaMask, or Coinbase Wallet.

getOwnedTokensByContract(ownerAddress, contractAddress, page)

Use this method to get a owned tokens in a given Cargo contract.

Arguments:

This method takes three arguments:

ownerAddress - string - required - The address in which to get owned tokens for

contractAddress - string -required - The contract to find owned tokens within

page - string - Optional page for pagination

Returns:

See the return type of getMintedTokens.

getContractsWithStake(ownerAddress)

Use this method to get a list of Cargo contract addresses that a given address owns tokens in.

Arguments:

This method takes one argument:

ownerAddress - string - required

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean - States if there was an error

response.data - Object

response.data.contracts - Array - List of contract addresses in which the owner address owns tokens.

Example:

cargo.api.getContractsWithStake(myAddress).then(res => {
if(!res.err){
console.log(res.data); // [0x..., ...]
}
});

getResaleItemsByCrateId(crateId)

Use this method to get all the resale items in the given crate.

Arguments:

This method takes one argument crateId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean stating if there was an error

response.data - This will be an Array of resale items for the given crate.

response.data[n] - Each item in the data array will have the following properties:

  • sellerAddress

  • tokenAddress

  • tokenId

  • metadata

  • price

  • fromVendor

  • resaleItemId

getBeneficiaryBalance(beneficiaryId)

Use the getBeneficiaryBalance method to get the balance in Wei that the specified beneficiary has available to withdraw.

Arguments:

This method takes one argument beneficiaryId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object

response.data.balance - string - This is the balance in Wei that the specified beneficiary has available to withdraw.

Example:

cargo.api.getBeneficiaryBalance('102969').then(response => {
const { err, data: { balance } } = response;
if(!err) {
// Do something with balance
}
});

getBeneficiaryById(beneficiaryId)

Use the getBeneficiaryById method to get information about the specified beneficiary.

This method takes one argument beneficiaryId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object

response.data.beneficiaryAddress - string - The address of the beneficiary

response.data.beneficiaryId - string - The ID of the beneficiary

response.data.commission - string - Percentage of sale that beneficiary will receive

response.data.lastWithdrawalTimestamp - string - Timestamp of the last time the beneficiary withdrew funds.

Example:

cargo.api.getBeneficiaryById('102969').then(response => {
const { err, data: {
beneficiaryAddress,
beneficiaryId,
commission,
lastWithdrawalTimestamp,
} } = response;
if(!err) {
// Do something with data
}
});

getBeneficiaryVendor(beneficiaryId)

Use the getBeneficiaryVendor method to get the vendor that the specified beneficiary is associated with.

Arguments:

This method takes one argument beneficiaryId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object

response.data.vendorAddress - string - The address of the vendor

response.data.vendorId - string - The ID of the vendor

response.data.crateId - string - The ID of the crate that the vendor and beneficiary are associated with.

Example:

cargo.api.getBeneficiaryVendor('102969').then(response => {
const { err, data } = response;
if(!err) {
const {
vendorAddress,
vendorId,
crateId,
} = data;
// Do something with data
}
});

getContract(contractName)

Use the getContract method to get the contract ABI and address (if available) of the specified contract.

Arguments:

This method takes one argument contractName which is a string that can be:

  • cargo

  • cargoAsset

  • cargoData

  • cargoSell

  • cargoToken - This contract does not have a specified address

  • cargoFunds

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object

response.data.address - string - The address of the contract

response.data.abi - Array<Object> - The contract ABI required to initialize a contract instance

Example:

cargo.api.getContract('cargoAsset').then(response => {
const { err, data } = response;
if(!err) {
const {
abi,
address,
} = data;
// Do something with data
}
});

getContractResaleItems(contractAddress, page)

Use this method to get a paginated list of resale items for a given contract.

Arguments:

This method takes two arguments:

contractAddress - string - required - Contract address to get resale items for

page - string - Page number for pagination

Returns:

This method returns a Promise which resolves and Object that contains:

response.err - boolean

response.data - ContractResaleItemsResponse

response.data.currentPage - string - The current page of resale items

response.data.totalPages - string - Total number of pages

response.data.total - string - Total number of resale items

response.data.resaleItems - Array<Object> - An array of resale items

response.data.resaleItems[n].sellerAddress - string - Address selling the item

response.data.resaleItems[n].tokenAddress - string - Address of token being sold

response.data.resaleItems[n].tokenId - string - Token ID being sold

response.data.resaleItems[n].resaleItemId - string - ID of the resale item

response.data.resaleItems[n].price - string - Price in Wei of resale item

response.data.resaleItems[n].metadata - TokenMetaData - Metadata for token including name, image, description

Returns:

This method returns a Promise which resolves an Object that contains:

response.err - boolean

response.data - Object

response.data[contractId] - Array - List of resale items

response.data[contractId][n].sellerAddress - string - Address of seller

response.data[contractId][n].tokenAddress - string - Address of token

response.data[contractId][n].tokenId - string - Token ID

response.data[contractId][n].metadata - Object - Metadata for the current token ID

response.data[contractId][n].price - string - Price in wei

response.data[contractId][n].fromVendor - boolean - If item is being sold by the vendor that created it

response.data[contractId][n].resaleItemId - string - Resale item ID for given item.

getCrateById(crateId)

Use the getCrateById method to get information about the specified crate.

Arguments:

This method takes one argument crateId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object

response.data.ownerAddress - string - The address of the crate owner

response.data.applicationFee - string - The percentage the owner will receive upon a sale made by a vendor.

response.data.hasCallbackContract - boolean - States whether or not the crate has an associated callback contract.

response.data.publicVendorCreation - boolean - States whether or not any address can add themselves as a vendor to the crate.

response.data.callbackContract - string - Address of the callback contract associated with this crate if one exists.

Example:

cargo.api.getCrateById('1111').then(response => {
const { err, data } = response;
if(!err) {
const {
ownerAddress,
applicationFee,
hasCallbackContract,
publicVendorCreation,
callbackContract,
} = data;
// Do something with data
}
});

getCrateVendors(crateId)

Use the getCrateVendors method to get information about the vendors in the specified crate.

Arguments:

This method takes one argument crateId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Array - A list of vendor objects.

response.data[n].vendorAddress - string - The address of the vendor

response.data[n].vendorId - string - The ID of the vendor

response.data[n].crateId - string - The ID of the crate.

Example:

cargo.api.getCrateVendors('1111').then(response => {
const { err, data } = response;
if(!err) {
data.forEach(vendor => {
const { vendorAddress, crateId } = vendor;
// Do something with data
});
}
});

getMintedTokens(tokenAddress, page)

Use the getMintedTokens method to get a list of minted tokens for a given contract. This method supports pagination.

Arguments:

This method takes two arguments:

tokenAddress - string - required - The contract address in which to view minted tokens

page - string - The current page for pagination, defaults to 1.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object - An object containing contract info, pagination info, and a list of tokens for the current pagination page.

response.data.vendorId - string - The ID of the vendor who created the contract

response.data.vendorAddress - string - The address of the vendor who created the contract

response.data.currentPage - string - The current page of tokens - 10 tokens per page

response.data.totalPages - string - The total number of pages for pagination

response.data.totalSupply - sting - Total supply of tokens in contract

response.data.tokens - Array - List of tokens in contract

response.data.tokens[n] - Object - An object containing information about the token:

// response.data.tokens[n]
{
metadata: {
// edition will be included if this token was part of a batch
// mint and the token URI has not been changed.
edition: string,
name: string,
description: string,
image: string,
metadata: {
// Additional arbitrary metadata set
// while creating token
}
},
owner: string,
supportsBatchMint: boolean,
tokenId: string,
tokenURI: string,
}

Example:

cargo.api.getMintedTokens(tokenAddress).then(response => {
const { err, data } = response;
if(!err) {
// do something with data
}
});

getOwnedResaleItemsByCrateId(crateId, address)

Use the getOwnedResaleItemsByCrateId method to get all the owned resale items for a given address in a given crate.

Arguments:

This method takes two arguments:

crateId - string - The crate ID that the owned resale items will belong to

address - string - The address that owns the resale items.

Returns:

This method returns a Promise which resolves an Object that contains the following:

response.err - boolean

response.data - An Array of Objects

response.data[n].fromVendor - boolean

response.data[n].price - string - the asking price of the item in wei

response.data[n].sellerAddress - string - the address of the seller

response.data[n].tokenAddress - string - the address of the token for sale

response.data[n].tokenId - string - the token ID which is for sale

response.data[n].resaleItemId - string - the ID of the given resale item

getOwnedResaleItems(address)

Use this method to get all the resale items owned by a given address.

Arguments:

address - string - The address for which to retrieve a list of owned resale items.

Returns:

This method returns a Promise that resolves an Object containing the following:

response.err - boolean

response.data - An Array of Objects

response.data[n].fromVendor - boolean

response.data[n].price - string - the asking price of the item in wei

response.data[n].sellerAddress - string - the address of the seller

response.data[n].tokenAddress - string - the address of the token for sale

response.data[n].tokenId - string - the token ID which is for sale

response.data[n].resaleItemId - string - the ID of the given resale item

getResellerBalance(resellerAddress)

Use the getResellerBalance method to get the balance of the specified reseller address.

Arguments:

This method takes one argument resellerAddress which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object.

response.data.balance - string - The balance, in Wei, the specified reseller has available to withdraw from the Cargo Funds contract.

Example:

cargo.api.getResellerBalance(resellerAddress).then(response => {
const { err, data } = response;
if(!err) {
const { balance } = data;
// Do something with data
}
});

getTokenContractById(tokenContractId)

Use the getTokenContractById method to get information about the specified token contract.

Arguments:

This method takes one argument tokenContractId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object.

response.data.tokenAddress - string - The address of the specified token.

response.data.name - string - The name of the specified token.

response.data.isLimitedSupply - boolean - States if the contract will allow for only a limited number of minted tokens.

response.data.symbol - string - Symbol of the token contract

response.data.creator - string - Address that created the token contract.

response.data.totalSupply - string - Number of minted tokens.

response.data.maxSupply - string - The maximum amount of tokens allowed to be created in the contract. Only valid if isLimitedSupply is true.

Example:

cargo.api.getTokenContractById(tokenContractId).then(response => {
const { err, data } = response;
if(!err) {
const { tokenAddress, tokenName } = data;
// Do something with data
}
});

getTokenContractByAddress(tokenContractAddress)

Use the getTokenContractByAddress method to get information about the specified token contract using its address.

Arguments:

This method takes one argument tokenContractAddress which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object.

response.data.tokenAddress - string - The address of the specified token.

response.data.name - string - The name of the specified token.

response.data.isLimitedSupply - boolean - States if the contract will allow for only a limited number of minted tokens.

response.data.symbol - string - Symbol of the token contract

response.data.tokenContractId - string - The ID Cargo assigned to this contract

response.data.creator - string - Address that created the token contract.

response.data.totalSupply - string - Number of minted tokens.

response.data.maxSupply - string - The maximum amount of tokens allowed to be created in the contract. Only valid if isLimitedSupply is true.

Example:

cargo.api.getTokenContractByAddress(tokenAddress).then(response => {
const { err, data } = response;
if(!err) {
const { tokenAddress, tokenName } = data;
// Do something with data
}
});

getTokenMetadata(tokenAddress, tokenId)

Use this method to get the parsed JSON response from the given token IDs public metadata file.

Arguments:

tokenAddress - string - the token address containing the token ID

tokenId - string - the token ID for which to retrieve the metadata.

Returns:

name - string - token name

image - string - public facing image representing the token

description - string - description of the token

metadata - Object - possible arbitrary object of data set when the token was minted

getVendorBeneficiaries(vendorId)

Use the getVendorBeneficiaries method to get a list of beneficiaries related to the specified vendor.

Arguments:

This method takes one argument vendorId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Array<Object> - A list of beneficiaries.

response.data[n].benficiaryAddress - string - The address of the beneficiary.

response.data[n].commission - string - The commission percentage of the beneficiary.

response.data[n].lastWithdrawalTimestamp - string - The timestamp of the beneficiaries last withdrawal. Will be 0 if there are no withdrawals.

Example:

cargo.api.getVendorBeneficiaries(vendorId).then(response => {
const { err, data } = response;
if(!err) {
data.forEach(beneficiary => {
// Do something with the data
});
}
});

getVendorById(vendorId)

Use the getVendorById method to get a information about the specified vendor.

Arguments:

This method takes one argument vendorId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object

response.data.vendorAddress - string - The address of the vendor.

response.data.crateId - string - The crate the specified vendor belongs to.

response.data.vendorId - string - The ID of the vendor.

Example:

cargo.api.getVendorById(vendorId).then(response => {
const { err, data } = response;
if(!err) {
const { vendorId, crateId } = data;
// Do something with data
}
});

getVendorByTokenId(tokenId)

Use the getVendorByTokenId method to get the vendor associated with the given token ID.

Arguments:

This method takes one argument tokenId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object

response.data.vendorAddress - The address of the vendor that created the given token ID.

response.data.crateId - The crate ID the returned vendor belongs to.

getVendorCrate(vendorId)

Use the getVendorCrate method to get information about the crate the specified vendor belongs to.

Arguments:

This method takes one argument vendorId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Object

response.data.crateId - string - The ID of the crate

response.data.ownerAddress - string - The address of the crate owner

response.data.applicationFee - string - The percentage the owner will receive upon a sale made by a vendor.

response.data.hasCallbackContract - boolean - States whether or not the crate has an associated callback contract.

response.data.publicVendorCreation - boolean - States whether or not any address can add themselves as a vendor to the crate.

response.data.callbackContract - string - Address of the callback contract associated with this crate if one exists.

Example:

cargo.api.getVendorCrate(vendorId).then(response => {
const { err, data } = response;
if(!err) {
// Do something with data
}
});

getVendorTokenContracts(vendorId)

Use the getVendorTokenContracts method to get a list of token contracts created by the specified vendor.

Arguments:

This method takes one argument vendorId which is a string.

Returns:

This method returns a Promise that will resolve with a response Object that contains the following:

response.err - boolean

response.data - Array<Object> - A list of objects containing information about a token contract

response.data[n].tokenAddress - string - The address of the token contract

response.data[n].tokenName - string - The name of the token

response.data[n].tokenContractId - string - The Id of the token contract

Example:

cargo.api.getVendorTokenContracts(vendorId).then(response => {
const { err, data } = response;
if(!err) {
data.forEach(token => {
// Do something with data
});
}
});