Skip to content

TP-Lab/TokenPocket-Protocol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

TokenPocket Protocol

该协议可以用于从网页和第三方App拉起TokenPocket钱包做授权 转账等操作

This protocol can be used to call TokenPocket do some actions from page or app。

Version:v1.0

目录 (Catelog)

使用场景 (How to use)

扫码拉起TokenPocket (Scan qrcode call TokenPocket)

页面拉起 ( Call from web page )

  • Scheme:tpoutside://pull.activity?param={}

转账示例,其他操作类似(Token transfer demo)

<a href='tpoutside://pull.activity?param={"Protocol":"ScanProtocol","version":"v1.0","blockchain":"eos","from":"aaaaaa123451","to":"cbzfb4a5s5zv","amount":"0.0001","contract":"eosio.token","symbol":"EOS","precision":"4","action":"transfer","memo":"test transfer from page"}'>Open TokenPocket to transfer eos</a><br/>

独立App拉起 ( Call from app )

第三方App可以拉起TokenPocket执行签名,转账等操作。TP sdk还支持MiniWallet,可以实现对于特定操作,第三方App不需要拉起钱包,直接在应用内部完成,体验更为流畅,具体使用请参照:https://github.com/TP-Lab/Mobile-SDK

Third-party apps can execute signatures, transfers, and etc actions by pull up the TokenPocket. TP SDK also support MiniWallet that can execute specific actions without leaving the app, which provides a better user experience. Please check it for the details:https://github.com/TP-Lab/Mobile-SDK

Dapp 浏览器打开url ( Call TokenPocket to open url with Dapp browser)

  • Scheme:tpdapp://open?params={}
<a href='tpdapp://open?params={"url": "https://dapp.mytokenpocket.vip/referendum/index.html#/", "chain": "EOS", "source":"xxx"}'>Open url with TokenPocket</a>

通用操作 (Common APIs)

1. Authorize

  • Parameters
{
    protocol	string   //protocol name here is TokenPocket
    version     string   // protocol version here is v1.0
    dappName    string   // optional
    dappIcon    string   // optional
    blockchain  string   // wallet type(eos bos eth moac )
    wallet      string   // account name
    action      string   // neccessary here is login
    actionId    string   // optional   
    callbackUrl string   // optional
    expired	    string   //expire time in seconds
    memo	    string   // optional
}
  • Success return data
{
   "sign": "SIG_K1_KZL9eR4cCQCJHpYHbh44yGrDqu4w8hHzQwb1xTk4Mcd4czqpw4jJUgg9DnWXzE3r",
   "timestamp": "1546613919", //in seconds
   "wallet": "eoseoseosacc", //account name
   "ref": "TokenPocket",
   "action":"login",
   "actionId":"ljsdjljdljf-xjlsdjfkj" //actionId from dapp
   "publickey": "EOS2TtWv19a9eYEQYB8NbGCM28nQNngWP4UcSjVYqtEz6kF7yCnPX",
   "permissions": ["active", "owner"],
   "result": 1
}

Cancel return data

{
   "action":"login",
   "actionId":"ljsdjljdljf-xjlsdjfkj" 
   "result": 0
}

2. 转账 (Token transfer)

  • Parameters
{
    protocol    string   //protocol name here is TokenPocket
    version     string   // protocol version here is v1.0
    dappName    string   // optional
    dappIcon    string   // optional
    action      string   // neccessary here is transfer
    actionId    string   // optional
    blockchain  string   //wallet type(eos bos eth moac )
    from        string   // optional
    to          string   // neccessary
    amount      number   // neccessary
    contract    string   // neccessary
    symbol      string   // neccessary
    precision   number   // neccessary
    memo        string   //optional
    expired	    string   // expire time in seconds
}
  • Success return data
{
"ref": "TokenPocket",
"txID": "588c6797534d09e8e0b149c06c11bfd6ca7b96f0d4bba87700fffe7a87b0d988",
"publickey": "EOSX1tWv19a9eKEQQB8Nb2wM28nYNngWP3UcSjVYqtjz6kF7yCnQ",
"action":"transfer",
"actionId":"ljsdljf-xljlsdjfl" //from dapp
"wallet": "eoseoseostes",
"permissions": ["active", "owner"],
"result": 1
}
  • Cancel return data
"action":"transfer",
"actionId":"ljsdljf-xljlsdjfl" //from dapp
"result": 0

3. PushTransaction

  • Parameters
    protocol    string  //protocol name here is TokenPocket
    version     string   // protocol version here is v1.0
    dappName    string   // optional
    dappIcon    string   // optional
    action      string   // neccessary here is pushTransaction
    actionId    string   // optional 
    blockchain  string   //wallet type(eos bos eth moac )
    actions     string   //actions data
    memo    string       //optional
  • Success return data
{
"ref": "TokenPocket",
"txID": "588c6797534d09e8e0b149c06c11bfd6ca7b96f0d4bba87700fffe7a87b0d988",
"publickey": "EOSX1tWv19a9eKEQQB8Nb2wM28nYNngWP3UcSjVYqtjz6kF7yCnQ",
"action":"pushTransaction",
"actionId":"ljsdljf-xljlsdjfl" 
"wallet": "eoseoseostes",
"permissions": ["active", "owner"],
"result": 1
}
  • Cancel return data
{
"action":"pushTransaction",
"actionId":"ljsdljf-xljlsdjfl"
"result": 0
}

4. 签名(Sign)

only version 0.6.5 or higher support this api

  • Parameters
    protocol    string  //protocol name here is TokenPocket
    version     string   // protocol version here is v1.0
    dappName    string   // optional
    dappIcon    string   // optional
    action      string   // neccessary here is sign
    actionId    string   // optional 
    blockchain  string   //wallet type(eos bos eth moac )
    message     string   //message to sign
    memo    string       //optional
  • Success return data
{
"ref": "TokenPocket",
"sign": "SIG_K1_JXLSDFLJLSKDJFKJ", //signed data
"publickey": "EOSX1tWv19a9eKEQQB8Nb2wM28nYNngWP3UcSjVYqtjz6kF7yCnQ",
"action":"pushTransaction",
"actionId":"ljsdljf-xljlsdjfl" 
"wallet": "eoseoseostes",
"permissions": ["active", "owner"],
"result": 1
}
  • Cancel return data
{
"action":"sign",
"actionId":"ljsdljf-xljlsdjfl"
"result": 0
}

5. Dapp 浏览器打开url (Dapp browser open url)

  • Parameters
"url": "https://dapp.mytokenpocket.vip/referendum/index.html#/",
"chain": "EOS", 
"source":"xxx"

MiniWallet 操作 (MiniWallet APIs)

1. 初始化sdk (Init SDK)

2. 设置blockchain 信息 (Set blockchain info)

  • Parameters
netType:NetTypeEnum 网络类型,包含主网和测试网(Nettype incluce mainnet and kyline jungle)
nodeUrl: string 

3. 设置插件信息 (Set plugin info)

  • Parameters
pluginUrl:  string  sdk功能需要,app可以自己在节点上部署插件,或者使用官方地址 (Used by sdk. app can delpoy the plugin or just use TokenPocket office plugin url)

4. 设置seed (Set seed to protect data)

  • Parameters
seed: string 非常重要,必须设置 (Very important, it is neccessary)

4. 修改seed (Modify seed)

  • Parameters
oldSeed: string 
newSeed: string

5. 获取已授权账号信息 (Get authed accounts

6. 检查权限是否存在 (Check permission bind to account)

account:  string 
perm:  string

7. 检查权限是否link到action (Check actions bind to permission)

  • Parameters
account:  string
perm: string
actions:  List<LinkAction> 需要检查的actions(The actions to be checked)

8. 清除本地授权 (clearAuth)

account: string 需要清除的账号 (Account to be clear)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published