/fcl-android

Primary LanguageKotlinMIT LicenseMIT

FCL Android

Connect your dapp to users, their wallets and Flow.
Read the docs»

Quickstart · Report Bug · Contribute · Discord

Overview


This reference documents all the methods available in the SDK, and explains in detail how these methods work. SDKs are open source, and you can use them according to the licence.


Feature list:

  • Sign in/up with Wallet provider
  • Configure app
  • Query cadence script with arguments
  • Send transaction with non-custodial mode (Blocto)
  • Send transaction with custodial wallet
  • Support all access api endpoint such as GetAccount and GetLastestBlock
  • Sign user message
  • Verify user signature
  • Publish to maven center

Todo list:

  • Support custom authz function

Getting Started

Installing

Use the configuration below to add this SDK to your project using Maven or Gradle.

Gradle

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}
implementation 'com.github.Outblock:fcl-android:0.09'

Config

Values only need to be set once. We recommend doing this once and as early in the life cycle as possible. To set a configuration value, the put method on the config instance needs to be called, the put method returns the config instance so they can be chained.

Fcl.config(
    appMetadata = AppMetadata(),
    env = FlowEnvironment(),
    // Not required: only required if you use the wallet connect function
    walletConnectMeta = WalletConnectMeta()
)

Common Configuration Keys

Name Example Description
accessNode (required) https://access-testnet.onflow.org API URL for the Flow Blockchain Access Node you want to be communicating with. See all available access node endpoints here.
location (required) https://foo.com Your application's site URL, can be requested by wallets and other services.
env testnet Used in conjunction with stored interactions. Possible values: local, canarynet, testnet, mainnet
appName Cryptokitties Your applications title, can be requested by wallets and other services.
appIcon https://fcl-discovery.onflow.org/images/blocto.png Url for your applications icon, can be requested by wallets and other services.

Wallet Interactions

  • These methods allows dapps to interact with FCL compatible wallets in order to authenticate the user and authorize transactions on their behalf.

authenticate

Calling this method will authenticate the current user via any wallet that supports FCL. Once called, FCL will initiate communication with the configured authn endpoint which lets the user select a wallet to authenticate with. Once the wallet provider has authenticated the user, FCL will set the values on the current user object for future use and authorization.

Fcl.authenticate(WalletProvider.DAPPER)

mutate

A convenience method that produces the needed authorization details for the current user to submit transactions to Flow. It defines a signing function that connects to a user's wallet provider to produce signatures to submit transactions.

Usage

Note: The default values for proposer, payer, and authorizations are already fcl.authz so there is no need to include these parameters, it is shown only for example purposes. See more on signing roles.

val tid = Fcl.mutate {
    cadence(
        """  
        transaction(test: String, testInt: Int) {           
	      prepare(signer: AuthAccount) {                
	          log(signer.address)   
	          log(test)   
	          log(testInt) 
          }
	}
	""".trimIndent()
    )
    arg { string("Test2") }
    arg { int(1) }
    gasLimit(1000)
}

Compatibility

Minimum Android SDK: FCL Android requires a minimum API level of 21.

License

See the LICENSE file for details.