tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
423 stars 271 forks source link

Sample Swap Code #552

Closed catstersol closed 2 weeks ago

catstersol commented 2 weeks ago

Do you have any samples of a Swap code using tron@beta?

I want to sell TRX to buy a meme coin and then sell meme coin for TRX.

Are these used to buy in sell or just send? in the JavaScript SDK I saw trxToTokenTransferInput but not see example in TypeScript BETA package.

    sendTrx(to: string, amount?: number, from?: string, options?: TransactionCommonOptions): Promise<Transaction>;
    sendToken(to: string, amount: number | undefined, tokenId: string, from?: string, options?: TransactionCommonOptions): Promise<Transaction>;

I see purchaseToken which might be for swap but I don't see anything about selling tokens.

Thanks

unicornonea commented 2 weeks ago

TronWeb have no any samples of a Swap code as it is the project's own code. TronWeb is just a pure JS SDK. Functions of sendTrx and sendToken are used to send the trc10 token and native TRX on TRON network.