Commit e2e13fd
authored
Add createAta instruction if needed for transfer (#266)
# Pull Request Description
Handles creating the AssociatedTokenAccount for a token if the receiver
doesn't have one initialized.
[Test
transaction](https://solscan.io/tx/2Bnh3J1hUUntTmJyiDX18vbhEDnGxKNYqnVoAJLm1nPqtBcqxP9LsaKdhe6UXpoXKma6cWvqyneMzHhSLPFZDKbi)
<img width="1391" alt="image"
src="https://github.com/user-attachments/assets/a8f70fa7-c75c-4974-ae74-6dbc811ffa01"
/>
## Changes Made
This PR adds the following changes:
<!-- List the key changes made in this PR -->
- Fixes issue when trying to send tokens to an account that has not
initialized the associated token account
## Implementation Details
<!-- Provide technical details about the implementation -->
- Checks for the account with a try-catch block
- Adds `createAssociatedTokenAccountInstruction` to the transaction if
needed
## Checklist
- [x] I have tested these changes locally
- [ ] I have updated the documentation
- [x] I have added a transaction link
- [ ] I have added the prompt used to test it1 file changed
+18
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
46 | 63 | | |
47 | 64 | | |
48 | 65 | | |
49 | 66 | | |
50 | | - | |
| 67 | + | |
51 | 68 | | |
52 | 69 | | |
53 | 70 | | |
| |||
0 commit comments