Coder Social home page Coder Social logo

neb.ios's Introduction

Install

1. Git clone this repo.

2. Drag iosSDK.xcodeproj file to your project.

1

3. Add link library.

2

4. Add header search path by dragging iosSDK folder to the setting area.

3

Usage

Wallet

Import NASSmartContracts.h file.

#import <NASSmartContracts.h>

1. Debug mode

[NASSmartContracts debug:YES]; // use the debug net

2. Check wallet APP

if (![NASSmartContracts nasNanoInstalled]) {
    // if wallet APP is not installed, go to AppStore.
    [NASSmartContracts goToNasNanoAppStore];
}

3. Pay

    self.sn = [NASSmartContracts randomCodeWithLength:32];
    NSError *error = [NASSmartContracts payNas:@(0.0001)
                                     toAddress:@"n1a4MqSPPND7d1UoYk32jXqKb5m5s3AN6wB"
                              withSerialNumber:self.sn
                                  forGoodsName:@"test1"
                                       andDesc:@"desc"];

4. Call contract function

    self.sn = [NASSmartContracts randomCodeWithLength:32];
    NSError *error = [NASSmartContracts callWithMethod:@"save"
                                               andArgs:@[@"key111", @"value111"]
                                                payNas:@(0)
                                             toAddress:@"n1zVUmH3BBebksT4LD5gMiWgNU9q3AMj3se"
                                      withSerialNumber:self.sn
                                          forGoodsName:@"test2"
                                               andDesc:@"desc2"];

5. Check status

    [NASSmartContracts checkStatusWithSerialNumber:self.sn
                             withCompletionHandler:^(NSDictionary *data) {
                                 NSData *json = [NSJSONSerialization dataWithJSONObject:data options:NSJSONWritingPrettyPrinted error:nil];
                                 NSString *string = [[NSString alloc] initWithData:json encoding:NSUTF8StringEncoding];
                                 NSLog(@"%@", string);
                             } errorHandler:^(NSInteger code, NSString *msg) {
                                 NSLog(@"%@", msg);
                             }];

API

Import NASApi.h file.

#import <NASApi.h>

1. Debug mode

Debug mode will connect to the debug net.

[NASApi debug:YES]; // use the debug net

2. call API

See the API document.

We do not define model for response and return a dictionary instead. You can use your favorite json library to parse the data.

completionHandler:(void (^)(NSDictionary *data))handler
errorHandler:(void (^)(NSString *msg))errorHandler

3. Contract

You can form a contract by calling contractWithSource:andSourceType:andFunction:andArgs.

    [NASApi contractWithSource:nil
                 andSourceType:nil
                   andFunction:@"transferValue"
                       andArgs:[@(500)]];

neb.ios's People

Contributors

bobby1i avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

neb.ios's Issues

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.