Skip to content

Commit

Permalink
Improve README
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Oct 10, 2021
1 parent 2acfcf2 commit 8f3b488
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 8f3b488

Please sign in to comment.