-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2acfcf2
commit 8f3b488
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,51 @@ $ cd my-project | |
$ go get github.com/gagliardetto/[email protected] | ||
``` | ||
|
||
## Pretty-Print transactions/instructions | ||
|
||
![pretty-printed](https://user-images.githubusercontent.com/15271561/136708519-399c9498-3d20-48d6-89fa-bdf43aac6d83.png) | ||
|
||
Instructions can be pretty-printed with the `EncodeTree` method on a `Transaction`: | ||
|
||
```go | ||
tx, err := solana.NewTransaction( | ||
[]solana.Instruction{ | ||
system.NewTransferInstruction( | ||
amount, | ||
accountFrom.PublicKey(), | ||
accountTo, | ||
).Build(), | ||
}, | ||
recent.Value.Blockhash, | ||
solana.TransactionPayer(accountFrom.PublicKey()), | ||
) | ||
|
||
... | ||
|
||
// Pretty print the transaction: | ||
tx.EncodeTree(text.NewTreeEncoder(os.Stdout, "Transfer SOL")) | ||
``` | ||
|
||
## SendAndConfirmTransaction | ||
|
||
You can wait for a transaction confirmation using the `sne` package tools (for a complete example: [see here](#transfer-sol-from-one-wallet-to-another-wallet)) | ||
|
||
```go | ||
// Send transaction, and wait for confirmation: | ||
sig, err := confirm.SendAndConfirmTransaction( | ||
context.TODO(), | ||
rpcClient, | ||
wsClient, | ||
tx, | ||
) | ||
if err != nil { | ||
panic(err) | ||
} | ||
spew.Dump(sig) | ||
``` | ||
|
||
The above command will send the transaction, and wait for its conformation. | ||
|
||
## Examples | ||
|
||
### Create account (wallet) | ||
|