SPL Token Program JS API
npm install @safecoin/safe-token@safecoin/safe-tokenA TypeScript library for interacting with the SPL Token and Token-2022 programs.
- TypeScript Docs
- FAQs (Frequently Asked Questions)
- Install
- Build from Source
Please ask questions in the Safecoin Stack Exchange: https://solana.stackexchange.com/
If you've found a bug or you'd like to request a feature, please
open an issue.
Please see upgrading from 0.1.x.
``shell`
npm install --save @safecoin/safe-token @safecoin/web3.js`
_OR_shell`
yarn add @safecoin/safe-token @safecoin/web3.js
0. Prerequisites
* Node 16+
* NPM 8+
1. Clone the project:
`shell`
git clone https://github.com/fair-exchange/safecoin-program-library.git
2. Navigate to the library:
`shell`
cd safecoin-program-library/token/js
3. Install the dependencies:
`shell`
npm install
4. Build the library:
`shell`
npm run build
5. Build the on-chain programs:
`shell`
npm run test:build-programs
6. Run the tests:
`shell`
npm run test
7. Run the example:
`shell`
npm run example
There are no breaking changes from 0.2.0, only new functionality for Token-2022.
When upgrading from safe-token 0.1.x, you may see the following error in your code:
``
import {TOKEN_PROGRAM_ID, Token, AccountLayout} from '@safecoin/safe-token';
^^^^^
SyntaxError: The requested module '@safecoin/safe-token' does not provide an export named 'Token'
The @safecoin/safe-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 @safecoin/safe-token@0.1.8
Otherwise you can find documentation on how to use new versions on the
SPL docs or
Safecoin Cookbook.