1.3.0 • Published 4 months ago

gochufun-sdk v1.3.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

gochu-sdk

gochufun-sdk helps people trade and get token details on tokens on the gochu.fun platform. This package is designed to simplify the process of interacting with swap transactions and token details in a secure manner.

Installation

To install the package, use npm or yarn:

npm install gochufun-sdk

or

yarn add gochufun-sdk

Usage

Importing the Package

To use the gochufun-sdk, you need to import the necessary classes and interfaces:

import { GochuFun } from 'gochufun-sdk';
import { SwapTransaction } from 'gochufun-sdk/dist/interfaces/swapInterface';

Creating an Instance of Gochu

To create an instance of the GochuFun class, you need to provide a secretKey and an accessKey:

const gochu = new GochuFun({
    secretKey: 'your-secret-key',
    accessKey: 'your-access-key'
});

Swap Transaction

To perform a swap transaction, use the swapTransaction method. The SwapTransaction interface looks like this:

export interface SwapTransaction {
  amount: number;
  is_buy: boolean;
  min_output: number;
  token_mint: string;
}

Example usage:

const transaction: SwapTransaction = {
    amount: 100, // in sol for buy, in token value for sell
    is_buy: true,
    min_output: 95,
    token_mint: 'your-token-mint'
};

gochu.swapTransaction(transaction)
    .then(response => {
        console.log('Swap transaction successful:', response);
    })
    .catch(error => {
        console.error('Error performing swap transaction:', error);
    });

Get Quote

To get a quote for a swap transaction, use the getQuote method using the SimSwap interface

const transaction: SimSwap = {
  amount: 100;
  is_buy: true;
  token_mint: 'token address';
}
gochu.getQuote(transaction)
    .then(response => {
        console.log('Quote received:', response);
    })
    .catch(error => {
        console.error('Error getting quote:', error);
    });

Get Token Details

To get details of a token, use the getToken method. The TokenDetails interface looks like this:

export interface TokenDetails {
    token_mint: string;
}

Example usage:

const transaction = {
    token_mint: 'your-token-mint'
}

gochu.getToken(transaction)
        .then(response => {
                console.log('Token details:', response);
        })
        .catch(error => {
                console.error('Error getting token details:', error);
        });
gochu.getToken(transaction)
    .then(response => {
        console.log('Token details:', response);
    })
    .catch(error => {
        console.error('Error getting token details:', error);
    });

Launch Token

To launch a new token, use the createToken method. The LaunchToken interface looks like this:

export interface LaunchToken {
    image: File;
    tokenName: string;
    tokenTicker: string;
    tokenDescription: string;
    twitter?: string;
    website?: string;
    telegram?: string;
    twitch?: string;
    isAntiPvp: boolean;
}

Example usage:

const newToken: LaunchToken = {
    image: new File([''], 'token.png', { type: 'image/png' }),
    tokenName: 'MyToken',
    tokenTicker: 'MTK',
    tokenDescription: 'This is a description of MyToken.',
    twitter: 'https://x.com/mytoken',
    website: 'https://www.mytoken.com',
    telegram: 't.me/@mytokenchannel',
    twitch: 'twitch.com/mytokenchannel',
    isAntiPvp: true
};

gochu.createToken(newToken)
    .then(response => {
        console.log('Token launched successfully:', response);
    })
    .catch(error => {
        console.error('Error launching token:', error);
    });

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

This project is licensed under the MIT License.

Contact

For any questions or support, please open an issue on the GitHub repository.

1.3.0

4 months ago

1.2.0

4 months ago

1.1.0

4 months ago

1.0.0

5 months ago