    import {Token} from '@solana/web3'

public class | source

# Token

An ERC20-like Token

## Static Method Summary

Static Public Methods
public static | async createNewToken(connection: Connection, owner: Account, supply: TokenAmount, name: string, symbol: string, decimals: number, programId: PublicKey): Promise<TokenAndPublicKey> Create a new Token |

## Constructor Summary

Public Constructor
public | constructor(connection: Connection, token: PublicKey, programId: PublicKey) Create a Token object attached to the specific token |

## Member Summary

Public Members
public | programId: PublicKey Program Identifier for the Token program |
public | token: PublicKey The public key identifying this token |

## Method Summary

Public Methods
public | async accountInfo(account: PublicKey): Promise<TokenAccountInfo> Retrieve account information |
public | async approve(owner: Account, account: PublicKey, delegate: PublicKey, amount: number | TokenAmount): Promise<void> Grant a third-party permission to transfer up the specified number of tokens from an account |
public | approveInstruction(owner: PublicKey, account: PublicKey, delegate: PublicKey, amount: number | TokenAmount): TransactionInstruction Construct an Approve instruction |
public | async newAccount(owner: Account, source: nullliteral | PublicKey): Promise<PublicKey> Create a new and empty token account. |
public | revoke(owner: Account, account: PublicKey, delegate: PublicKey): Promise<void> Remove approval for the transfer of any remaining tokens |
public | revokeInstruction(owner: PublicKey, account: PublicKey, delegate: PublicKey): TransactionInstruction Construct an Revoke instruction |
public | async setOwner(owner: Account, account: PublicKey, newOwner: PublicKey): Promise<void> Assign a new owner to the account |
public | setOwnerInstruction(owner: PublicKey, account: PublicKey, newOwner: PublicKey): TransactionInstruction Construct a SetOwner instruction |
public | async tokenInfo(): Promise<TokenInfo> Retrieve token information |
public | async transfer(owner: Account, source: PublicKey, destination: PublicKey, amount: number | TokenAmount): Promise<?<span>TransactionSignature> Transfer tokens to another account |
public | async transferInstruction(owner: PublicKey, source: PublicKey, destination: PublicKey, amount: number | TokenAmount): Promise<TransactionInstruction> Construct a Transfer instruction |

## Static Public Methods

### public static async createNewToken(connection: Connection, owner: Account, supply: TokenAmount, name: string, symbol: string, decimals: number, programId: PublicKey): Promise<TokenAndPublicKey> source

Create a new Token

#### Params:

Name | Type | Attribute | Description
connection | Connection |  | The connection to use
owner | Account |  | User account that will own the returned Token Account
supply | TokenAmount |  | Total supply of the new token
name | string |  | Descriptive name of this token
symbol | string |  | Symbol for this token
decimals | number |  | Location of the decimal place

programId

PublicKey

- optional
- default: undefined

Optional token programId, uses the system programId by default

#### Return:

Promise<TokenAndPublicKey> | Token object for the newly minted token, Public key of the Token Account holding the total supply of new tokens

## Public Constructors

### public constructor(connection: Connection, token: PublicKey, programId: PublicKey) source

Create a Token object attached to the specific token

#### Params:

Name | Type | Attribute | Description
connection | Connection |  | The connection to use
token | PublicKey |  | Public key of the token

programId

PublicKey

- optional
- default: undefined

Optional token programId, uses the system programId by default

## Public Members

### public programId: PublicKey source

Program Identifier for the Token program

### public token: PublicKey source

The public key identifying this token

## Public Methods

### public async accountInfo(account: PublicKey): Promise<TokenAccountInfo> source

Retrieve account information

#### Params:

Name | Type | Attribute | Description
account | PublicKey |  | Public key of the token account

#### Return:

Promise<TokenAccountInfo>

### public async approve(owner: Account, account: PublicKey, delegate: PublicKey, amount: number | TokenAmount): Promise<void> source

Grant a third-party permission to transfer up the specified number of tokens from an account

#### Params:

Name | Type | Attribute | Description
owner | Account |  | Owner of the source token account
account | PublicKey |  | Public key of the token account
delegate | PublicKey |  | Token account authorized to perform a transfer tokens from the source account
amount | number | TokenAmount |  | Maximum number of tokens the delegate may transfer

#### Return:

Promise<void>

### public approveInstruction(owner: PublicKey, account: PublicKey, delegate: PublicKey, amount: number | TokenAmount): TransactionInstruction source

Construct an Approve instruction

#### Params:

Name | Type | Attribute | Description
owner | PublicKey |  | Owner of the source token account
account | PublicKey |  | Public key of the token account
delegate | PublicKey |  | Token account authorized to perform a transfer tokens from the source account
amount | number | TokenAmount |  | Maximum number of tokens the delegate may transfer

#### Return:

TransactionInstruction

### public async newAccount(owner: Account, source: nullliteral | PublicKey): Promise<PublicKey> source

Create a new and empty token account.

This account may then be used as a `transfer()` or `approve()` destination

#### Params:

Name | Type | Attribute | Description
owner | Account |  | User account that will own the new token account

source

nullliteral | PublicKey

- optional
- default: undefined

If not null, create a delegate account that when authorized may transfer tokens from this `source` account

#### Return:

Promise<PublicKey> | Public key of the new empty token account

### public revoke(owner: Account, account: PublicKey, delegate: PublicKey): Promise<void> source

Remove approval for the transfer of any remaining tokens

#### Params:

Name | Type | Attribute | Description
owner | Account |  | Owner of the source token account
account | PublicKey |  | Public key of the token account
delegate | PublicKey |  | Token account to revoke authorization from

#### Return:

Promise<void>

### public revokeInstruction(owner: PublicKey, account: PublicKey, delegate: PublicKey): TransactionInstruction source

Construct an Revoke instruction

#### Params:

Name | Type | Attribute | Description
owner | PublicKey |  | Owner of the source token account
account | PublicKey |  | Public key of the token account
delegate | PublicKey |  | Token account authorized to perform a transfer tokens from the source account

#### Return:

TransactionInstruction

### public async setOwner(owner: Account, account: PublicKey, newOwner: PublicKey): Promise<void> source

Assign a new owner to the account

#### Params:

Name | Type | Attribute | Description
owner | Account |  | Owner of the token account
account | PublicKey |  | Public key of the token account
newOwner | PublicKey |  | New owner of the token account

#### Return:

Promise<void>

### public setOwnerInstruction(owner: PublicKey, account: PublicKey, newOwner: PublicKey): TransactionInstruction source

Construct a SetOwner instruction

#### Params:

Name | Type | Attribute | Description
owner | PublicKey |  | Owner of the token account
account | PublicKey |  | Public key of the token account
newOwner | PublicKey |  | New owner of the token account

#### Return:

TransactionInstruction

### public async tokenInfo(): Promise<TokenInfo> source

Retrieve token information

#### Return:

Promise<TokenInfo>

### public async transfer(owner: Account, source: PublicKey, destination: PublicKey, amount: number | TokenAmount): Promise<?<span>TransactionSignature> source

Transfer tokens to another account

#### Params:

Name | Type | Attribute | Description
owner | Account |  | Owner of the source token account
source | PublicKey |  | Source token account
destination | PublicKey |  | Destination token account
amount | number | TokenAmount |  | Number of tokens to transfer

#### Return:

Promise<?<span>TransactionSignature>

### public async transferInstruction(owner: PublicKey, source: PublicKey, destination: PublicKey, amount: number | TokenAmount): Promise<TransactionInstruction> source

Construct a Transfer instruction

#### Params:

Name | Type | Attribute | Description
owner | PublicKey |  | Owner of the source token account
source | PublicKey |  | Source token account
destination | PublicKey |  | Destination token account
amount | number | TokenAmount |  | Number of tokens to transfer

#### Return:

Promise<TransactionInstruction>