Skip to content

Canoe-Finance/Solana-Flutter-DeFi-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solana-Flutter-DeFi-SDK

Flutter’s SDK is the leading technology behind many social mobile Apps. It will enrich the ecosystem of Canoe SDK, and make mobile Apps abundant. image Canoe's first social App, Dating APP, powered by open-source DeFi SDK for developers. Flutter is a fast mobile App development language and its feature is similar to web3js. Most of the blockchain relies upon JS, so the flutter framework and Dart language are easy to call on the blockchain API compared with other mobile App languages. Mobile teams can quickly integrate Flutter like StepN, which uses the Flutter framework too. Each public chain must provide the Flutter open source infra tools and Canoe will deliver more features to more public chains.

Solana Wallet

Build the wallet module on the basis of cryptoplease-dart

  • Borsh
  • Crypto Please
    • Send Crypto with just a link
    • Create a new wallet
    • Import your existing wallet by typing your recovery phrase (12 words or 24 words)
    • Send and Receive SOL Token
    • Send and Receive SPL Tokens like USDT, USDC
    • History of transactions
  • JSON rpc_client
  • Dart library for Solana
    • Complete implementation of the JSON RPC api.
    • Complete implementation of a subscription client (using the JSON RPC subscription variant of the API).
    • Complete implementation of the following programs
      • System Program
      • Token Program
      • Memo Program
      • Stake Program
      • Associated Token Account Program
    • Support for key generation/importing using Hierarchical Deterministic derivation.
    • Support for importing keys by using a bip39 seed phrase.
    • Support for importing keys by using raw private key bytes.
    • Transaction encoding and signing.
    • Building and signing offline transactions, as well as convenience methods to sign and send the transaction. Also, the ability to listen for a status change on a given signature. The latter can be used to wait for a transaction to be in the confirmed or finalized state.
    • Support for decoding Metaplex NFT metadata.

Development

IMPORTANT current sdk is unstable right now, api may change in future.

  • Initialize
final sdk = SolanaDeFiSDK.initialize();
// for devnet
final sdk = SolanaDeFiSDK.initialize(env: SolanaID.devnet);
  • Wallet
// create wallet
import 'package:bip39/bip39.dart' as bip39;
final mnemonic = bip39.generateMnemonic();

// import wallet
final wallet = await sdk.initWalletFromMnemonic(/*String mnemonic*/);
final wallet = await sdk.initWalletFromPrivateKey(/*String key*/);
// you can get wallet later by
final wallet = sdk.wallet!;
  • Balance & NFTs
// get sol balance
final int balance = await sdk.getBalance(/*String address*/);
// get token accounts
final List<TokenAccountData> accounts = await sdk.getTokenAccounts(/*String address*/);
// get nfts
final NFTScanGetTransactionResponse response = await sdk.getNFTs(/*String address*/);
final List<NFTTransactionRecord>? nfts = response.data?.records;
  • Transfer
final tx =
        await sdk.transfer(/*Wallet source*/, /*String destinationAddress*/, /*int amount*/);
// or
final tx =
        await sdk.transferLamports(/*String receiver*/, lamports: /*int amount*/);
  • SWAP
// 1. get routes by https://quote-api.jup.ag/v1/quote
final routes =
        await sdk.getSwapQuote(/*String inputAddress*/, /*String outputAddress*/, /*int amount*/);
// 2. get transactions by your chosen route by https://quote-api.jup.ag/v1/swap
final transactions =
        await sdk.getSwapTxs(wallet.address, routes!.first!);
// 3. do swap!
await sdk.swap(wallet, transactions);
  • Cross Chain
// 1. get cross-chain transaction by https://wormhole.canoe.finance [https://github.com/Canoe-Finance/wormhole-node]
final transactionTx = await sdk.cross(wallet,
          mint: /*String mintAddress*/, targetAddress: /*String ethAddress*/, amount: /*int amount*/);
// 2. Redeem at https://www.portalbridge.com/#/redeem with returned transaction id before

NFT Dating APP

Chat

Used google messages

  • Message text
  • Message image
  • Audio call
  • Video call

Location

Used google maps

Storage

Used google firestore

Monitor

Used sentry api

Swap

Used jupiter api

Cross chain

Used canoe wormhole

Send request http, and get the base64 transaction data, then send to blockchain. More info

Releases

No releases published

Packages

No packages published

Languages