examples

package
v0.41.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 15 Imported by: 9

README

Emulator Examples

This package contains code samples that interact with the Flow Emulator.

Running the emulator with the Flow CLI

The emulator is bundled with the Flow CLI, a command-line interface for working with Flow.

Installation

Follow these steps to install the Flow CLI.

Starting the server

Start the emulator by running the following command in this directory:

flow emulator start -v

The -v flag enables verbose log output, which is useful for testing

Running the examples

In a separate process, run any of the example programs below. Watch the emulator logs to see transaction output.

Get Blocks

Get blocks by ID, height or latest on Flow.

make get-blocks
Get Accounts

Get accounts by address in specific block on Flow

make get-accounts
Get Events

Get events emitted by transactions.

make get-events
Get Collection

Get collections by ID.

make get-collection
Execute Script

Execute cadence script.

make send-transactions
Send Transaction

Send a transaction.

make send-transactions
Create Account

Create a new account on Flow.

make create-account
Add Account Key

Add a key to an existing account.

make add-account-key
Deploy Contract

Deploy a Cadence smart contract.

make deploy-contract
Transaction Arguments

Submit a transaction with Cadence arguments.

make transaction-arguments
Transaction Signing
Single Party, Single Signature

Sign a transaction with a single account.

make single-party
Single Party, Multiple Signatures

Sign a transaction with a single account using multiple signatures.

make single-party-multisig
Multiple Parties

Sign a transaction with multiple accounts.

make multi-party
Multiple Parties, Two authorizers

Sign a transaction with multiple accounts and authorize for both of them.

make multi-party-two-authorizers
Multiple Parties, Multiple Signatures

Sign a transaction with multiple accounts using multiple signatures.

make multi-party-multisig
Verify Signature
User Signature

Sign an arbitrary user message.

make user-signature
User Signature Verify all

Sign an arbitrary user message and verify it by using the public keys on an account respecting the weights of each key.

make user-signature-verify-all
User Signature Verify any

Sign an arbitrary user message and verify it by using the public keys on an account. Return success if any public key on the account can sign the message.

make user-signature-verify-all
Verify Events

Verify events emitted in a block.

make verify-events

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateAccount

func CreateAccount(flowClient access.Client, publicKeys []*flow.AccountKey) *flow.Account

func CreateAccountWithContracts added in v0.12.0

func CreateAccountWithContracts(flowClient access.Client, publicKeys []*flow.AccountKey, contracts []templates.Contract) *flow.Account

func FundAccountInEmulator added in v0.15.0

func FundAccountInEmulator(flowClient access.Client, address flow.Address, amount float64)

FundAccountInEmulator Mints FLOW to an account. Minting only works in an emulator environment.

func GetReferenceBlockId added in v0.11.0

func GetReferenceBlockId(flowClient access.Client) flow.Identifier

func Handle

func Handle(err error)

func NewFlowGRPCClient added in v0.25.0

func NewFlowGRPCClient() *grpc.Client

func RandomAccount added in v0.4.0

func RandomAccount(flowClient access.Client) (flow.Address, *flow.AccountKey, crypto.Signer)

func RandomPrivateKey

func RandomPrivateKey() crypto.PrivateKey

RandomPrivateKey returns a randomly generated ECDSA P-256 private key.

func RandomTransaction added in v0.24.0

func RandomTransaction(flowClient access.Client) *flow.Transaction

func ReadFile

func ReadFile(path string) string

ReadFile reads a file from the file system.

func ServiceAccount added in v0.4.0

func ServiceAccount(flowClient access.Client) (flow.Address, *flow.AccountKey, crypto.Signer)

func WaitForSeal

func WaitForSeal(ctx context.Context, c access.Client, id flow.Identifier) *flow.TransactionResult

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL