Skip to content

Commit

Permalink
chore: README was not updated somehow, updating again
Browse files Browse the repository at this point in the history
  • Loading branch information
randomshinichi committed Sep 11, 2019
1 parent 0b6e64b commit 1b7c26d
Showing 1 changed file with 13 additions and 28 deletions.
41 changes: 13 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,22 @@ When using the `Context` methods in `helpers.go`, additional conveniences for AE
For a painless experience when building transactions, use the `Context` methods.
```
import "github.com/aeternity/aepp-sdk-go/aeternity"
...
// create a Context for the address you're going to sign the transaction
// with, and an aeternity node to talk to/query the address's nonce.
ctx := aeternity.NewContextFromURL(node, alice.Address, false)
// create the SpendTransaction
tx, err := ctx.SpendTx(alice.Address, bob.Address, *amount, *fee, msg)
if err != nil {
t.Error(err)
}
// create a Context for the address you're going to sign the transaction
// with, and an aeternity node to talk to/query the address's nonce.
ctx, node := aeternity.NewContextFromURL("http://localhost:3013", alice.Address, false)
// optional: minimize the fee to save money!
est, _ := tx.FeeEstimate()
fmt.Println("Estimated vs Actual Fee:", est, tx.Fee)
tx.Fee = *est
// create the SpendTransaction
tx, err := ctx.SpendTx(alice.Address, bob.Address, *utils.NewIntFromUint64(10000), aeternity.Config.Client.Fee, []byte("Reason"))
if err != nil {
os.Exit(1)
}
signedTx, hash, signature, err := aeternity.SignHashTx(acc, tx, aeternity.Config.Node.NetworkID)
if err != nil {
t.Fatal(err)
}
// optional: minimize the fee to save money!
est, _ := tx.FeeEstimate()
fmt.Println("Estimated vs Actual Fee:", est, tx.Fee)
tx.Fee = *est
// transform the tx into a tx_base64encodedstring so you can HTTP POST it
signedTxStr, err := aeternity.SerializeTx(signedTx)
if err != nil {
t.Error(err)
}
err = aeternity.BroadcastTransaction(node, signedTxStr)
if err != nil {
t.Fatal(err)
}
signedTxStr, hash, signature, blockHeight, blockHash, err := aeternity.SignBroadcastWaitTransaction(tx, alice, node, aeternity.Config.Node.NetworkID, 10)
```

0 comments on commit 1b7c26d

Please sign in to comment.