@gorbchain-xyz/token
v0.4.91
Published
Gabana Token Program JS API
Downloads
5
Readme
@gorbchain-xyz/token
A TypeScript library for interacting with the Gorbchain Token and Token-2022 programs.
Links
FAQs
How can I get support?
Please ask questions in the Gorbchain Stack Exchange: https://stackexchange.gorbchain.xyz/
If you've found a bug or you'd like to request a feature, please open an issue.
No export named Token
Please see upgrading from 0.1.x.
Install
npm install --save @gorbchain-xyz/token @gorbchain-xyz/web3.jsOR
yarn add @gorbchain-xyz/token @gorbchain-xyz/web3.jsBuild from Source
- Prerequisites
- Node 16+
- PNPM
If you have Node 16+, you can activate PNPM with Corepack.
- Clone the project:
git clone https://github.com/gorblin-gabana/gorbchain-library.git- Navigate to the root of the repository:
cd gorbchain-library- Install the dependencies:
pnpm install- Build the libraries in the repository:
pnpm run build- Navigate to the Token library:
cd token/js- Build the on-chain programs:
pnpm run test:build-programs- Run the tests:
pnpm run test- Run the example:
pnpm run exampleDynamic Program Address Configuration
This library does not use hardcoded program addresses. You must set the program addresses at runtime before using any functionality:
import { setTokenProgramConfig } from '@gorbchain-xyz/token';
import { PublicKey } from '@gorbchain-xyz/web3.js';
setTokenProgramConfig({
TOKEN_PROGRAM_ID: new PublicKey('...'),
TOKEN_2022_PROGRAM_ID: new PublicKey('...'),
ASSOCIATED_TOKEN_PROGRAM_ID: new PublicKey('...'),
NATIVE_MINT: new PublicKey('...'),
NATIVE_MINT_2022: new PublicKey('...'),
});You can now use the library and it will use your provided addresses everywhere.
Upgrading
Upgrading from 0.2.0
There are no breaking changes from 0.2.0, only new functionality for Token-2022.
Upgrading from 0.1.x
When upgrading from spl-token 0.1.x, you may see the following error in your code:
import {TOKEN_PROGRAM_ID, Token, AccountLayout} from '@gorbchain-xyz/token';
^^^^^
SyntaxError: The requested module '@gorbchain-xyz/token' does not provide an export named 'Token'The @gorbchain-xyz/token library as of version 0.2.0 does not have the Token
class. Instead the actions are split up and exported separately.
To use the old version, install it with:
npm install @gorbchain-xyz/[email protected]Otherwise you can find documentation on how to use new versions on the Gorbchain docs or Gorbchain Cookbook.
