Skip to content
基于SimpleWallet 协议的SDK
C Objective-C
Branch: master
Clone or download
Pull request Compare This branch is 21 commits ahead of lynnerrr:master.
Latest commit 75ad83c Aug 14, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
MathWalletDemos.xcodeproj Support Block Aug 14, 2019
MathWalletDemos Support Block Aug 14, 2019
MathWalletSDK Support Block Aug 14, 2019
README.md Support block Aug 14, 2019
README_EN.md
README_KO.md
plist.jpeg
urlschemes.jpeg update Sep 26, 2018

README.md

MathWalletSDK-iOS

基于SimpleWallet协议的iOS SDK

支持公链 ETH,EOS,EOSFORCE 等

English Readme

Korean Readme

如何使用?

1、配置URL Schemes

Xcode工程info.plist-> URL types -> URL Schemes

URL Schemes

iOS9以上需要在info.plist进行如下设置:

URL Schemes

2、注册URL Schemes和处理URL

#import <MathWalletSDK/MathWalletSDK.h>
  
  
@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    [MathWalletAPI registerAppURLSchemes:@"mathwalletdemos"];
    return YES;
}


-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options{
    BOOL handle = [MathWalletAPI handleURL:url];
    return handle;
}

@end

3、使用MathWallet进行登录操作

  MathWalletLoginReq *loginReq = [[MathWalletLoginReq alloc] init];
  // 公链标识
  loginReq.blockchain = @"eosio";   // eosio、eosforce、ethereum
  // DApp信息
  loginReq.dappIcon = @"http://www.mathwallet.org/images/download/wallet_cn.png";
  loginReq.dappName = @"Demos";
  // DApp Server
  loginReq.uuID = @"本次登录uid";
  loginReq.loginUrl = @"登录回调";
  loginReq.expired = [NSNumber numberWithLong:([NSDate date].timeIntervalSince1970 + 60)];
  loginReq.loginMemo = @"Memo";

  [MathWalletAPI sendReq:loginReq response:^(MathWalletResp *resq) {
        NSLog(@"%@",resq.data);
    }];

4、使用MathWallet进行转账操作

  MathWalletTransferReq *transferReq = [[MathWalletTransferReq alloc] init];
  // 公链标识
  transferReq.blockchain = @"eosio";  // eosio、eosforce、ethereum
  // DApp信息
  transferReq.dappIcon = @"http://www.mathwallet.org/images/download/wallet_cn.png";
  transferReq.dappName = @"Demos";
  // 转账信息
  transferReq.from = @"eosioaccount";
  transferReq.to = @"eosioaccount";
  transferReq.amount = @"1.0000";
  transferReq.precision = @(4);
  transferReq.symbol = @"EOS";
  transferReq.contract = @"eosio.token";
  transferReq.dappData = @"备注";

  transferReq.desc = @"这是展示在钱包中的描述";
  transferReq.expired = [NSNumber numberWithLong:([NSDate date].timeIntervalSince1970 + 60)];
  
  [MathWalletAPI sendReq:transferReq response:^(MathWalletResp *resq) {
        NSLog(@"%@",resq.data);
    }];

5、使用MathWallet进行自定义交易操作(执行合约)

  MathWalletTransactionReq *transactionReq = [[MathWalletTransactionReq alloc] init];
  // 公链标识
  transactionReq.blockchain = @"eosio";
  // DApp信息
  transactionReq.dappIcon = @"http://www.mathwallet.org/images/download/wallet_cn.png";
  transactionReq.dappName = @"Demos";
  // 转账信息
  transactionReq.from = @"testaccount1";
  transactionReq.actions = @[
                          @{
                              @"code":@"eosio.token",
                              @"action":@"transfer",
                              @"binargs":@"4086089a7ad7bef6c0a6eb6c1acda891010000000000000004454f530000000006e5a487e6b3a8"
                              }
                          ];

  transactionReq.desc = @"这是展示在钱包中的描述";
  transactionReq.expired = [NSNumber numberWithLong:[NSDate date].timeIntervalSince1970];
  [MathWalletAPI sendReq:transactionReq response:^(MathWalletResp *resq) {
        NSLog(@"%@",resq.data);
    }];

6、使用MathWallet 签名消息

    MathWalletSignMessageReq *signMessageReq = [[MathWalletSignMessageReq alloc] init];
    // 公链标识
    signMessageReq.blockchain = @"eosio";
    // DApp信息
    signMessageReq.dappIcon = @"http://www.mathwallet.org/images/download/wallet_cn.png";
    signMessageReq.dappName = @"MathWalletSDK-Demos";
    // 签名信息
    signMessageReq.from = @"testaccount1";
    signMessageReq.message = @"我是要签名的信息";
    signMessageReq.isHex = @(NO);
    signMessageReq.desc = @"这是展示在钱包中的描述";
    
    [MathWalletAPI sendReq:signMessageReq response:^(MathWalletResp *resq) {
        NSLog(@"%@",resq.data);
    }];

7、使用MathWallet 打开DApp

    MathWalletOpenURLReq *openURLReq = [[MathWalletOpenURLReq alloc] init];
    // 公链标识
    openURLReq.blockchain = @"eosio";
    // DApp信息
    openURLReq.dappIcon = @"http://www.mathwallet.org/images/download/wallet_cn.png";
    openURLReq.dappName = @"Demos";
    // 转账信息
    openURLReq.dappUrl = @"http://www.redpacketeos.com";
    openURLReq.desc = @"这是展示在钱包中的描述";
    [MathWalletAPI sendReq:openURLReq response:^(MathWalletResp *resq) {
        NSLog(@"%@",resq.data);
    }];
You can’t perform that action at this time.