An iOS SDK of Nebulas payment
Switch branches/tags
Nothing to show
Clone or download
bobby
Latest commit 47caf96 Jul 5, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo fix thread crash May 30, 2018
iosSDK fix bug in formating parameters Jul 5, 2018
.gitignore first commit May 28, 2018
1.png update README.md May 29, 2018
2.png update README.md May 29, 2018
3.png update README.md May 29, 2018
README.md Update README.md Jun 2, 2018

README.md

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)]];