An open API service indexing awesome lists of open source software.

https://github.com/solana-program/token-2022

The SPL Token 2022 program and its clients
https://github.com/solana-program/token-2022

Last synced: 6 months ago
JSON representation

The SPL Token 2022 program and its clients

Awesome Lists containing this project

README

          

# Token 2022




This template should help get you started developing Solana programs. Let's walk through this generated program repository and see what's included.

## Project setup

The first thing you'll want to do is install NPM dependencies which will allow you to access all the scripts and tools provided by this template.

```sh
pnpm install
```

## Managing programs

You'll notice a `program` folder in the root of this repository. This is where your generated Solana program is located.

Whilst only one program gets generated, note that you can have as many programs as you like in this repository.
Whenever you add a new program folder to this repository, remember to add it to the `members` array of your root `Cargo.toml` file.
That way, your programs will be recognized by the following scripts that allow you to build, test, format and lint your programs respectively.

```sh
pnpm programs:build
pnpm programs:test
pnpm programs:format
pnpm programs:lint
```

## IDL

You may use the following [IDL](https://github.com/solana-program/token-2022/blob/main/program/idl.json) in your programs.

## Generating clients

Once your programs' IDLs have been generated, you can generate clients for them using the following command.

```sh
pnpm generate:clients
```

Alternatively, you can use the `generate` script to generate both the IDLs and the clients at once.

```sh
pnpm generate
```

## Managing clients

The following clients are available for your programs. You may use the following links to learn more about each client.

- [JS client](./clients/js)
- [Rust client](./clients/rust)

## Starting and stopping the local validator

The following script is available to start your local validator.
In order to run the local validator you must also have the spl-elgamal-registry program built.

```sh
pnpm confidential-transfer:elgamal-registry:build # you only need to run this once
pnpm validator:start
```

By default, if a local validator is already running, the script will be skipped. You may use the `validator:restart` script instead to force the validator to restart.

```sh
pnpm validator:restart
```

Finally, you may stop the local validator using the following command.

```sh
pnpm validator:stop
```

## Using external programs in your validator

If your program requires any external programs to be running, you'll want to in your local validator.

You can do this by adding their program addresses to the `program-dependencies` array in the `Cargo.toml` of your program.

```toml
program-dependencies = [
"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
"noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV",
]
```

Next time you build your program and run your validator, these external programs will automatically be fetched from mainnet and used in your local validator.

```sh
pnpm programs:build
pnpm validator:restart
```