Skip to content

Waves Keeper

Ruslan Prokofev edited this page Sep 6, 2019 · 5 revisions

Mobile keeper is part of Waves client app, it designed to send or sign transactions created in third-party applications, but keep your seed-phrase in the safe place and do not show it to that applications. It is care about Waves blockchain users safety.

For using Mobile keeper you must create an application with this Waves Mobile SDK, create one of allowed transactions and send it via special intent to keeper. User will see details of your transaction and accept or reject it. You can create two options for keeper: sign or send. Both ways returns signed transaction after user accept, but send also add transaction to Waves blockchain.

Now we support only three main types: transfer, data and invoke script transactions. In future keeper will support all types. You can find examples of transactions here and all examples of this tutotial is here

1. Install WaveSDK before Waves Keeper using

How install WavesSDK?

2. Configure dApp before Waves Keeper using

To transfer data between DApp and Keeper, you must register the URL scheme. How register the URL scheme?

Add WavesKeeper initialization to application() method in your AppDelegate class by editing 'AppDelegate.swift' file. After that you will be able to use WavesKeeper features in the app.

You must initialization the WavesKeeper and transfer data about DApp

  • name - Name Application
  • iconUrl - Icon Application
  • schemeUrl - URL Scheme
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        var url: URL?
        
        if let path = launchOptions?[.url] as? String {
            url = URL(string: path)
        }
        
        let sourceApplication = (launchOptions?[.sourceApplication] as? String) ?? ""
        
        
        WavesSDK.initialization(servicesPlugins: .init(data: [],
                                                       node: [],
                                                       matcher: []),
                                enviroment: .init(server: .testNet, timestampServerDiff: 0))
        
        WavesKeeper.initialization(application: .init(name: "Name DApp",
                                                      iconUrl: "Icon Dapp",
                                                      schemeUrl: "schemeDApp"))
        
        return true
    }

The Waves Keeper calling your application and send response via URL The URL transfer to WavesKeeper

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        
        let sourceApplication: String = (options[UIApplication.OpenURLOptionsKey.sourceApplication] as? String) ?? ""
        
        return WavesKeeper.shared.applicationOpenURL(url, sourceApplication)
    }

3. Prepare and send transaction to Waves keeper for add it to Waves blockchain or just get signification from it

    // Preparing Send transaction, use also DataTransaction or InvokeScriptTransaction

      let query: NodeService
                .Query
                .Transaction
                .Transfer = .init(recipient: "3PNaua1fMrQm4TArqeTuakmY1u985CgMRk6",
                                  assetId: "WAVES",
                                  amount: 1000,
                                  fee: 100000,
                                  attachment: "First",
                                  feeAssetId: "WAVES",
                                  chainId: "T")

    // 1. Send transaction to Waves keeper for send                              
            WavesKeeper
                .shared
                .send(.transfer(query))
                .subscribe(onNext: { (response) in
                    print("Eee boy \(response)")
                })
                .disposed(by: disposeBag)

    // 2. Data transaction to Waves keeper for sign

               WavesKeeper
                .shared
                .sign(.transfer(query))
                .subscribe(onNext: { (response) in
                    print("Eee boy \(response)")
                })
                .disposed(by: disposeBag)

After transaction signification you can send transaction to blockchain. Remember timestamp valid for +/- 90 min and you can't change timestamp without changes in signature.