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

Commit 4d2dc28

Browse files
tanjiehuiJie Hui Tan
andauthored
Add deposit NFT example (#242)
Co-authored-by: Jie Hui Tan <[email protected]>
1 parent 0e18af6 commit 4d2dc28

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

examples/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ Update [depositEth.ts](./depositEth.ts#L14) with your deposit amount then run
3737
yarn deposit-eth
3838
```
3939

40+
## Deposit NFT
41+
42+
Update [depositNft.ts](./depositNft.ts#L14) with your token address and id then run
43+
44+
```sh
45+
yarn deposit-nft
46+
```
47+
4048
## Prepare Eth Withdrawal
4149

4250
Update [createEthWithdrawal.ts](./createEthWithdrawal.ts#L12) with your withdrawal amount then run

examples/depositNft.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Config, ImmutableX } from '@imtbl/core-sdk';
2+
import { generateWalletConnection } from './libs/walletConnection';
3+
4+
(async () => {
5+
try {
6+
const walletConnection = await generateWalletConnection('goerli');
7+
8+
// IMX class client
9+
const client = new ImmutableX(Config.SANDBOX);
10+
11+
// Deposit ERC721
12+
const depositResponse = await client.deposit(walletConnection.ethSigner, {
13+
type: 'ERC721',
14+
tokenId: '', // TOKEN_ID
15+
tokenAddress: '' // COLLECTION_CONTRACT_ADDRESS
16+
});
17+
18+
console.log('depositResponse', depositResponse);
19+
} catch (err) {
20+
console.error(err);
21+
process.exit(1);
22+
}
23+
})();

examples/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"create-exchange-transfer": "ts-node -r dotenv/config createExchangeTransfer.ts",
1111
"create-nft-primary-txn": "ts-node -r dotenv/config createNftPrimaryTransaction.ts",
1212
"deposit-eth": "ts-node -r dotenv/config depositEth.ts",
13+
"deposit-nft": "ts-node -r dotenv/config depositNft.ts",
1314
"create-eth-withdrawal": "ts-node -r dotenv/config createEthWithdrawal.ts",
1415
"complete-eth-withdrawal": "ts-node -r dotenv/config completeEthWithdrawal.ts",
1516
"create-project": "ts-node -r dotenv/config createProject.ts",

0 commit comments

Comments
 (0)