Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Assets examples (#266)
Browse files Browse the repository at this point in the history
* Assets examples

* linting

* linting
  • Loading branch information
coreyneal-immutable authored Feb 6, 2023
1 parent 0122385 commit 6147be2
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
14 changes: 14 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,20 @@ Update [listTransfers.ts](./listTransfers.ts#L10) the desired fields and then ru
```sh
yarn list-transfers
```
## Get asset
Update [getAsset.ts](./getAsset.ts#L10) the token address and token id and then run

```sh
yarn get-asset
```

## List assets
Update [listAssets.ts](./listAssets.ts#L10) the desired fields and then run

```sh
yarn list-assets
```

## Get user

Update [getUser.ts](./getUser.ts#L10) with the wallet address and then run
Expand Down
20 changes: 20 additions & 0 deletions examples/getAsset.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ImmutableX, Config, AssetsApiGetAssetRequest } from '@imtbl/core-sdk';

(async () => {
const imxClient = new ImmutableX(Config.SANDBOX);

const assetParams: AssetsApiGetAssetRequest = {
tokenAddress: '', //Address of the ERC721 contract
tokenId: '', //Either ERC721 token ID or internal IMX ID
includeFees: false, //Set flag to include fees associated with the asset
};

try {
const assetResponse = await imxClient.getAsset(assetParams);

console.log('assetResponse', assetResponse);
} catch (error) {
console.error(error);
process.exit(1);
}
})();
37 changes: 37 additions & 0 deletions examples/listAssets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
ImmutableX,
Config,
AssetsApiListAssetsRequest,
} from '@imtbl/core-sdk';

(async () => {
const imxClient = new ImmutableX(Config.SANDBOX);

const assetParams: AssetsApiListAssetsRequest = {
collection: '', // Collection contract address,
name: '', // Name of the asset to search
user: '', // Ethereum address of the user who owns these assets
pageSize: 200, // Page size of the result
auxiliaryFeePercentages: '', // Comma separated string of fee percentages that are to be paired with auxiliary_fee_recipients
auxiliaryFeeRecipients: '', // Comma separated string of fee recipients that are to be paired with auxiliary_fee_percentages
buyOrders: false, //Set flag to true to fetch an array of buy order details with accepted status associated with the asset
cursor: '', // Cursor for pagination
direction: '', // Direction to sort (asc/desc)
includeFees: false, // Set flag to include fees associated with the asset
metadata: '', // URL JSON-encoded metadata filters for these assets. Javascript example: encodeURI(JSON.stringify({'proto':['1147'],'quality':['Meteorite']}))
orderBy: 'name', // Property to sort by | Allowed values: updated_at, name
sellOrders: false, // Set flag to true to fetch an array of sell order details with accepted status associated with the asset
status: 'imx', // Status of these assets | Allowed values: eth, imx, preparing_withdrawal, withdrawable, burned
updatedMaxTimestamp: '', // Maximum timestamp for when these assets were last updated, in ISO 8601 UTC format. Example: '2022-05-27T00:10:22Z'
updatedMinTimestamp: '', // Minimum timestamp for when these assets were last updated, in ISO 8601 UTC format. Example: '2022-05-27T00:10:22Z'
};

try {
const assetResponse = await imxClient.listAssets(assetParams);

console.log('assetResponse', assetResponse);
} catch (error) {
console.error(error);
process.exit(1);
}
})();
2 changes: 2 additions & 0 deletions examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"mint": "ts-node -r dotenv/config mint.ts",
"list-mints": "ts-node -r dotenv/config listMints.ts",
"get-mint": "ts-node -r dotenv/config getMint.ts",
"get-asset": "ts-node -r dotenv/config getAsset.ts",
"list-assets": "ts-node -r dotenv/config listAssets.ts",
"transfer-nfts": "ts-node -r dotenv/config transferNfts.ts",
"transfer-eth": "ts-node -r dotenv/config transferEth.ts",
"transfer-erc20": "ts-node -r dotenv/config transferErc20.ts",
Expand Down

0 comments on commit 6147be2

Please sign in to comment.