Reputation: 11
I have several wallets in evm. I give their X token access to my main wallet by calling Contract(x).approve() function. Thus i can make operations with these wallets. Now i want to do same thing on solana with solana web3 library. However i cannot find any function that gives allowance to my main wallet. The X token on Solana uses solana token program.
Upvotes: 1
Views: 1918
Reputation: 8462
Correct, you cannot approve tokens using the normal @solana/web3.js
package, so you'll have to use the @solana/spl-token
package in one of two ways:
approve
does it from the client (https://github.com/solana-labs/solana-program-library/blob/edec44180c3349abd77677acb2270a00121f2936/token/js/client/token.js#L905)createApproveInstruction
creates the instruction which you must include in a Transasction
and then send (https://github.com/solana-labs/solana-program-library/blob/edec44180c3349abd77677acb2270a00121f2936/token/js/client/token.js#L1570)Upvotes: 1