rckprtr / pumpdotfun-sdk

PumpDotFun SDK
MIT License
186 stars 78 forks source link

error: "Provider' only refers to a type, but is being used as a value here." should this be AnchorProvider as Provider seems to be deprecated? #12

Closed JS0832 closed 2 months ago

JS0832 commented 2 months ago

I tried to make a simple token creation program and I get the error as in the title.

`import { Connection,Keypair,ConfirmOptions} from '@solana/web3.js'; import { PumpFunSDK, CreateTokenMetadata } from './src'; import { Provider,Wallet } from '@project-serum/anchor'; import bs58 from './bs58';

export function getKeyPairFromPrivateKey(key: string) { return Keypair.fromSecretKey( new Uint8Array(bs58.decode(key) )); }

const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');

const keypair = getKeyPairFromPrivateKey("some private key") const wallet = new Wallet(keypair); const options: ConfirmOptions = { preflightCommitment: 'confirmed', commitment: 'confirmed', };

const provider = new Provider(connection, wallet,options); //'Provider' only refers to a type, but is being used as a value here.ts(2693) <- error

const creator = Keypair.generate(); const mint = Keypair.generate(); const createTokenMetadata: CreateTokenMetadata = { name: "MyToken", symbol: "MTK", description: "My awesome token", filePath: "./path/to/token/image.png", twitter: "@mytoken", telegram: "@mytokentelegram", website: "https://mytokenwebsite.com" };

const buyAmountSol = BigInt(10000); // 1 SOL in lamports

const pumpFunSDK = new PumpFunSDK(provider);

(async () => { const result = await pumpFunSDK.createAndBuy(creator, mint, createTokenMetadata, buyAmountSol); console.log(result); })();`

Shouldn't the sdk use AnchorProvider instead or am I doing something very wrong? Many thanks.

rckprtr commented 2 months ago

Updated the README as its outdated, please check out https://github.com/rckprtr/pumpdotfun-sdk/blob/main/example/basic/index.ts for a basic example of usage.