GithubHelp home page GithubHelp logo

alike010000 / near-api-swift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from near/near-api-swift

0.0 0.0 0.0 295 KB

Interact with NEAR blockchain from iOS and OS X apps using Swift

License: MIT License

Ruby 0.45% Objective-C 0.19% Swift 99.36%

near-api-swift's Introduction

nearclientios

Build Status Version License MIT Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Usage

import nearclientios
class ViewController: UIViewController, WalletSignInDelegate {
  private var walletAccount: WalletAccount?
  private var near: Near?

  override func viewDidLoad() {
    super.viewDidLoad()
    let keyStore = KeychainKeyStore(keychain: .init(service: "example.keystore"))
    let config = NearConfig(
      networkId: "testnet", // "default" for mainnet 
      nodeUrl: URL(string: "https://rpc.testnet.near.org")!, // "https://rpc.mainnet.near.org" for mainnet
      masterAccount: nil,
      keyPath: nil,
      helperUrl: nil,
      initialBalance: nil,
      providerType: .jsonRPC(URL(string: "https://rpc.testnet.near.org")!), // "https://rpc.mainnet.near.org" for mainnet
      signerType: .inMemory(keyStore),
      keyStore: keyStore,
      contractName: nil,
      walletUrl: "https://wallet.testnet.near.org" // "https://wallet.near.org" for mainnet
    )
    near = try Near(config: config)
    walletAccount = try! WalletAccount(near: near!, authService: DefaultAuthService.shared) // a failed try here represents a configuration error, not a runtime error. It's safe to store a `WalletAccount!`.
    let appName = UIApplication.name ?? "signInTitle"
    DefaultAuthService.shared.walletSignIn = self
    try! await walletAccount!.requestSignIn(contractId: nil, title: appName, presentingViewController: self)
  }
  func completeSignIn(url: URL) async {
    try! await walletAccount?.completeSignIn(url: url)
    MainActor.run {
      //do any additional UI work on the main thread after sign in is complete
    }
  }
}

Requirements

nearclientios makes use of Swift's async/await and thus requires iOS 13.

Installation

nearclientios is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'nearclientios'

Author

NEAR Inc

License

nearclientios is available under the MIT license. See the LICENSE file for more info.

near-api-swift's People

Contributors

samingle avatar kvnm avatar dmitrykurochka avatar miancadonc avatar s2v avatar vgrichina avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.