86 lines
2.1 KiB
Markdown
86 lines
2.1 KiB
Markdown
|
|
# @dbis-thirdweb/tokens
|
||
|
|
|
||
|
|
ERC20/721/1155 token deployment and management for Chain 138.
|
||
|
|
|
||
|
|
## Usage
|
||
|
|
|
||
|
|
### Token Factory
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
import { createTokenFactory } from '@dbis-thirdweb/tokens';
|
||
|
|
import { ThirdwebSDK } from '@thirdweb-dev/sdk';
|
||
|
|
import { chain138 } from '@dbis-thirdweb/chain';
|
||
|
|
|
||
|
|
const sdk = new ThirdwebSDK(chain138, privateKey);
|
||
|
|
const factory = createTokenFactory(sdk);
|
||
|
|
|
||
|
|
// Deploy ERC20
|
||
|
|
const erc20Address = await factory.deployERC20({
|
||
|
|
name: 'My Token',
|
||
|
|
symbol: 'MTK',
|
||
|
|
initialSupply: '1000000',
|
||
|
|
});
|
||
|
|
|
||
|
|
// Deploy ERC721
|
||
|
|
const erc721Address = await factory.deployERC721({
|
||
|
|
name: 'My NFT',
|
||
|
|
symbol: 'MNFT',
|
||
|
|
});
|
||
|
|
|
||
|
|
// Deploy ERC1155
|
||
|
|
const erc1155Address = await factory.deployERC1155({
|
||
|
|
name: 'My Edition',
|
||
|
|
});
|
||
|
|
```
|
||
|
|
|
||
|
|
### ERC20 Operations
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
import { mintERC20, transferERC20, getERC20Balance } from '@dbis-thirdweb/tokens';
|
||
|
|
|
||
|
|
await mintERC20(sdk, erc20Address, '1000', recipientAddress);
|
||
|
|
await transferERC20(sdk, erc20Address, recipientAddress, '100');
|
||
|
|
const balance = await getERC20Balance(sdk, erc20Address, address);
|
||
|
|
```
|
||
|
|
|
||
|
|
### ERC721 Operations
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
import { mintERC721, transferERC721, getERC721Metadata } from '@dbis-thirdweb/tokens';
|
||
|
|
|
||
|
|
const tokenId = await mintERC721(sdk, erc721Address, {
|
||
|
|
name: 'My NFT #1',
|
||
|
|
description: 'Description',
|
||
|
|
image: 'ipfs://...',
|
||
|
|
});
|
||
|
|
|
||
|
|
await transferERC721(sdk, erc721Address, tokenId, recipientAddress);
|
||
|
|
const metadata = await getERC721Metadata(sdk, erc721Address, tokenId);
|
||
|
|
```
|
||
|
|
|
||
|
|
### ERC1155 Operations
|
||
|
|
|
||
|
|
```typescript
|
||
|
|
import { mintERC1155, batchMintERC1155, getERC1155Balance } from '@dbis-thirdweb/tokens';
|
||
|
|
|
||
|
|
await mintERC1155(sdk, erc1155Address, 0n, '100', {
|
||
|
|
name: 'Edition #1',
|
||
|
|
image: 'ipfs://...',
|
||
|
|
});
|
||
|
|
|
||
|
|
await batchMintERC1155(sdk, erc1155Address, [
|
||
|
|
{ tokenId: 1n, amount: '50', metadata: {...} },
|
||
|
|
{ tokenId: 2n, amount: '25', metadata: {...} },
|
||
|
|
]);
|
||
|
|
|
||
|
|
const balance = await getERC1155Balance(sdk, erc1155Address, address, 0n);
|
||
|
|
```
|
||
|
|
|
||
|
|
## Features
|
||
|
|
|
||
|
|
- ERC20 deploy/mint/transfer/balance
|
||
|
|
- ERC721 deploy/mint/transfer/metadata
|
||
|
|
- ERC1155 deploy/batch mint/transfer
|
||
|
|
- Metadata hosting strategy (IPFS/thirdweb storage)
|
||
|
|
- Token factory utilities
|