'Give another account ability to transfer portion of SOL - Solana
In SPL Token there is a function called Approve which gives the delegate account the ability to transfer an amount of tokens. So far I can only see this working for a custom token.
Is it possible to give the delegate account the ability to transfer SOL?
The flow I am after is:
- Client grants permission to transfer X SOL
- API creates a transaction to perform multiple actions including transferring SOL from the client's account to a system account
Resources:
- Approve function: https://docs.rs/spl-token/3.0.1/spl_token/instruction/fn.approve.html
Solution 1:[1]
Your best bet is to wrap your SOL into an SPL token account (mint So11111111111111111111111111111111111111112
) and use the SOL as an SPL token, e.g.:
$ spl-token wrap 1
Wrapping 1 SOL into GJTxcnA5Sydy8YRhqvHxbQ5QNsPyRKvzguodQEaShJje
Signature: 4f4s5QVMKisLS6ihZcXXPbiBAzjnvkBcp2A7KKER7k9DwJ4qjbVsQBKv2rAyBumXC1gLn8EJQhwWkybE4yJGnw2Y
$ spl-token approve So11111111111111111111111111111111111111112 1 pubkey_to_approve_to
More info about wrapping at https://spl.solana.com/token#wrapping-sol and https://spl.solana.com/token#example-wrapping-sol-in-a-token
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Jon C |