Skip to content

Latest commit

 

History

History
135 lines (86 loc) · 5.35 KB

README.md

File metadata and controls

135 lines (86 loc) · 5.35 KB

JVM SDK - Kotlin Examples

This package contains runnable code examples that use the Flow JVM SDK to interact with the Flow blockchain in Kotlin. The examples use the Flow Emulator to simulate a live network connection.

Table of Contents

Running the emulator with the Flow CLI

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

Installation

This repository is configured to run with Cadence 1.0. Follow these steps to install the Cadence 1.0 CLI.

Running the examples

Each code example has a corresponding test file located in /kotlin-example/src/test. Each test file provides a series of runnable functions which boot up the emulator and invoke the corresponding code example. We recommend using IntelliJ IDEA (see the free Community Edition here) to interact with and run the tests. However, you can also trigger an individual test run with ./gradlew :kotlin-example:test --tests "com.example.MyTestClass.myTestMethod".

Examples summary

Below is a list of all Kotlin code examples currently supported in this repo:

Get Blocks

Get blocks by ID, height, or latest sealed.

  • Get the latest sealed block
  • Get block by ID
  • Get block by height

Get Accounts

Get accounts by address.

  • Get account balance
  • Get account from the latest block
  • Get account from block by height

Get Events

Get events emitted by transactions.

  • Get events for height range
  • Get events for block IDs
  • Get events directly from transaction result

Get Collection

Get collections by ID.

Get Execution Data

Get execution data by block ID.

Get Network Parameters

Get the current network parameters.

Get Transactions

Get transactions.

  • Get transaction
  • Get transaction result

Sending Transactions

Sending transactions.

  • Send transaction
  • Send transaction with arguments

Execute Script

Execute a Cadence script.

  • Execute a simple Cadence script
  • Execute a more complex Cadence script with arguments

Create Account

Create a new account on Flow.

Add Account Key

Add a key to an existing account.

Deploy Contract

Deploy a Cadence smart contract.

Transaction Signing

Common paradigms for signing transactions.

  • Single party, single signature
  • Single party, multiple signatures
  • Multiple parties
  • Multiple parties, 2 authorizers
  • Multiple parties, multiple signatures

Verifying Signatures

Common paradigms for signing messages.

  • Signing an arbitrary message.
  • Signing an arbitrary user message and verifying it using the public keys on an account, respecting the weights of each key.
  • Signing an arbitrary user message and verifying it using the public keys on an account. Return success if any public key on the account can sign the message.

Streaming Events and Execution Data

Utilizing the Access API subscription endpoints to stream event and execution data.

  • Streaming events.
  • Streaming events and reconnecting in the event of a failure.
  • Streaming execution data.