Changelog
Recent updates to the Flow Go SDK
v0.10.1
Invalid date
- Updated sdk examples (#103) @janezpodhostnik
- ID -> Index (#104) @Kay-Zee
- crypto/cloudkms: Add initial draft of Google Cloud KMS integration (#96) @psiemens
- Update flow.AccountKey to match latest protocol changes (#101) @psiemens
- Added BlockTimestamp to BlockEvents response (#100) @janezpodhostnik
🛠 Improvements
- Add json tags to key struct and KeyFromResourceID func (#105) @Kay-Zee
Version 0.10.0
Friday, September 18th 2020
Network Compatibility
| Emulator v0.7.0 | Emulator v0.8.0 | Emulator v0.9.0 | Emulator v0.10.0 | Testnet | Mainnet |
|---|---|---|---|---|---|
| ❌ | ❌ | ✅ | ✅ | ✅ | ✅ |
💥 Breaking Changes
- Update
onflow/flow/protobuf/go/flowto v0.1.5 (#98) @turbolent
🐛 Bug Fixes
- Add missing
EXPIREDvalue toflow.TransactionStatusenum (#90) @rrrkren - Do not deploy empty code string on account creation (#97) @psiemens
⭐ Enhancements
- Add transaction example that uses 2 authorizers (#89) @bjartek
- Improve ECDSA documentation (#94) @tarakby
- Improve documentation for the
flow.Transactionfields (#91) @turbolent
Version 0.9.0
Monday, August 10th 2020
Network Compatibility
| Emulator v0.5.0 | Emulator v0.6.0 | Emulator v0.7.0 | Testnet | Mainnet |
|---|---|---|---|---|
| ❌ | ✅ | ✅ | ✅ | ✅ |
💥 Breaking Changes
Upgrade to Cadence v0.8.0: https://github.com/onflow/cadence/releases/tag/v0.8.0
- Arguments passed to
cadence.Value#WithTypeare now typed as pointers (*cadence.Type) rather than values (cadence.Type).
Example:
myEventType := cadence.EventType{...})
// this 👇
myEvent := cadence.NewEvent(...).WithType(myEventType)
// changes to this 👇
myEvent := cadence.NewEvent(...).WithType(&myEventType)Version 0.8.0
Wednesday, July 15th 2020
Network Compatibility
| Emulator v0.4.0 | Emulator v0.5.0 | Emulator v0.6.0 | Testnet | Mainnet |
|---|---|---|---|---|
| ❌ | ❌ | ✅ | ❌ | ❌ |
💥 Breaking Changes
GetAccountAtLatestBlock (https://github.com/onflow/flow-go-sdk/pull/85)
The GetAccount Access API RPC method has been renamed to GetAccountAtLatestBlock to better reflect its functionality and differentiate it from the upcoming GetAccountAtBlockHeight method.
v0.10.1
Invalid date
- ID -> Index (#104) @Kay-Zee
- crypto/cloudkms: Add initial draft of Google Cloud KMS integration (#96) @psiemens
- Update flow.AccountKey to match latest protocol changes (#101) @psiemens
- Added BlockTimestamp to BlockEvents response (#100) @janezpodhostnik
Version 0.7.0
Wednesday, July 8th 2020
Network Compatibility
| Emulator v0.4.0 | Emulator v0.5.0 | Testnet | Mainnet |
|---|---|---|---|
| ❌ | ✅ | ❌ | ❌ |
💥 Breaking Changes
Transaction arguments (https://github.com/onflow/flow-go-sdk/pull/67)
Due to a bug that was causing transaction arguments to be encoded in an inconsistent manner (https://github.com/onflow/flow-go-sdk/issues/66), the flow.Transaction#Arguments field has been updated to be typed as [][]byte rather than []cadence.Value.
This in turn necessitated a change to the flow.Transaction#AddArgument function:
AddArgumentfunction signature changed tofunc (tx *Transaction) AddArgument(arg cadence.Value) error- This function performs JSON-CDC encoding of the provided argument, and therefore has the potential to produce an error.
AddRawArgumentfunction introduced:func (tx *Transaction) AddRawArgument(arg []byte) *Transaction- This is a chainable function that can be used to add pre-encoded arguments.
Transaction templates (https://github.com/onflow/flow-go-sdk/pull/78)
The helpers defined in the templates package have changed to use parameterized transactions and arguments rather than naive string templates. This approach is more flexible and will allow templates to be easily shared between different SDK implementations.
This change breaks the old API by changing the return type of each template function to *flow.Transaction.
For example, this is the signature for templates.CreateAccount:
// CreateAccount generates a transaction that creates a new account.
//
// This template accepts a list of public keys and a code argument, both of which are optional.
//
// The final argument is the address of the account that will pay the account creation fee.
// This account is added as a transaction authorizer and therefore must sign the resulting transaction.
func CreateAccount(accountKeys []*flow.AccountKey, code []byte, payer flow.Address) *flow.TransactionThe partial transactions returned by these helpers functions can later be signed and sent to the Access API.
Cadence v0.5.0 (https://github.com/onflow/flow-go-sdk/pull/77)
The Go SDK has been upgraded to use the latest Cadence release. Please view the Cadence release notes for an overview of the features and changes introduced in this release: https://github.com/onflow/cadence/releases/tag/v0.5.0
🐛 Bug Fixes
- See transaction arguments change above
⭐ Features
- Added
flow.SignUserMessagefunction to support signing of user messages (https://github.com/onflow/flow-go-sdk/pull/76). Example usage
Version 0.6.0
Thursday, June 25th 2020
💥 Breaking Changes
RPC errors
This release introduces a dedicated client.RPCError type for errors returned by the Access API. (#62)
client.RPCError implements the interface defined in the status.FromError function from the google.golang.org/grpc/status package:
import "google.golang.org/grpc/status"
res, err := c.GetTransactionResult(...)
if err != nil {
s, ok := status.FromError(err)
...
}client.RPCError can also be unwrapped to produce the original gRPC error:
grpcErr := errors.Unwrap(rpcErr)Removed crypto.KeyType enum
The crypto.KeyType enum was removed because it is no longer required by the rest of the SDK. (#58)
Version 0.5.0
Monday, June 15th 2020
💥 Breaking Changes
Script arguments
Added support for script arguments, which allows Cadence values to be passed as arguments to ExecuteScript calls. This change affects the following functions on client.Client:
ExecuteScriptAtLatestBlockExecuteScriptAtBlockIDExecuteScriptAtBlockHeight
Each of these functions now takes an additional argument of type []cadence.Value. For scripts that do not require any arguments, simply pass nil:
result, _ := c.ExecuteScriptAtLatestBlock(ctx, myBlockID, myScript, nil)Note: script arguments are not yet supported in the emulator.
🐛 Bug Fixes
- Added thread safety to the
flow.Transaction#IDfunction. This fixes a previous race condition that would occur when generating transaction IDs from multiple routines.
⭐ Features
- Added
flow.TransactionStatusExpiredstatus to theflow.TransactionStatusenum.- Note: transaction expiry is not yet supported by the emulator.
Version 0.4.1
Friday, June 5th 2020
🐛 Bug Fixes
- Patch the following Access API client methods to support versions of the Access API that do not include a
Timestampfield inBlockandBlockHeaderresponses: (#47)GetLatestBlock,GetBlockAtHeight,GetBlockByIDGetLatestBlockHeader,GetBlockHeaderAtHeight,GetBlockHeaderByID
Version 0.4.0
Wednesday, June 3rd 2020

💥 Breaking Changes
Cadence
- Cadence has been upgraded to
v0.4.0: https://github.com/onflow/cadence/releases/tag/v0.4.0
The AuthAccount constructor signature has changed from this:
AuthAccount(publicKeys: [[Int]], code: [Int])to this:
let account = AuthAccount(payer: AuthAccount)This allows for another account that isn't the transaction payer to pay for the creation of a new account.
The constructor also no longer takes publicKeys and code arguments -- these fields must be provided via the addPublicKey and setCode methods.
Example
This transaction:
transaction {
prepare() {
let acct = AuthAccount(keys: keys, code: code)
}
}now becomes this:
transaction {
prepare(signer: AuthAccount) {
let acct = AuthAccount(payer: signer)
for key in keys {
acct.addPublicKey(key)
}
acct.setCode(code)
}
}This also means that the account creation transaction requires an authorizer. For cases where you were previously signing with a single payer, you can make this change to use the same payer to pay the transaction fee and account creation fee.
// Old code
tx := flow.NewTransaction().
SetScript(createAccount).
SetPayer(payerAddress)
_, = tx.SignEnvelope(payerAddress, payerKey, payerSigner)// New code
tx := flow.NewTransaction().
SetScript(createAccount).
SetPayer(payerAddress).
AddAuthorizer(payerAddress) // add payerAddress as an authorizer
_, = tx.SignEnvelope(payerAddress, payerKey, payerSigner)Account Addresses
Changes introduced in https://github.com/onflow/flow-go-sdk/pull/36 and https://github.com/onflow/flow-go-sdk/pull/41.
- Address length has changed from 20 bytes to 8 bytes (64 bits).
- Address generation no longer follows a monotonic sequence; addresses are now generated in a deterministic but non-monotonic sequence.
- Each network (
Mainnet,TestnetandEmulator) uses different parameters for address generation, meaning that addresses are not compatible across networks.
AddressGenerator
The flow.AddressGenerator struct can be used to generate addresses for a specific network. Here's an example:
gen := flow.NewAddressGenerator(flow.Mainnet)
// get the current address
addressA := gen.Address()
// increment state
gen.Next()
// get the next address
addressB := gen.Address()
// skip to index 42
gen.SetIndex(42)
addressC := gen.Address()
// check if an address is valid for a network
if !addressC.IsValid(flow.Testnet) {
fmt.Println("Invalid testnet address!")
}Other Breaking Changes
flow.ZeroAddresswas renamed toflow.EmptyAddressflow.ZeroIDwas renamed toflow.EmptyID
⭐ Features
- Transactions now support Cadence arguments, which can be used with parameterized scripts to create reusable transactions. (https://github.com/onflow/flow-go-sdk/pull/43) Example
flow.AccountKey#SetPublicKeynow automatically sets theSigAlgofield based on the provided public key. (https://github.com/onflow/flow-go-sdk/pull/35)flow.BlockHeadernow includes aTimestampfield. (https://github.com/onflow/flow-go-sdk/pull/42)- The
flow.Mainnet,flow.Testnetandflow.EmulatorChainIDconstants were introduced to differentiate between different networks.
⚙️ Installing & Upgrading
go get github.com/onflow/flow-go-sdk@v0.4.0