所有API都應該帶入參數:
- callback: 將結果POST到指定的URL
- source: 開發商名稱
- apiKey: Coolwallet發放給DAPP開發商的金鑰
依據callback將結果POST到指定的URL。以getAccounts為例,想要callback的URL為:
https://relay.host/?session=xxx
假設source為:
JOYSO
假設apiKey為:
ooo
將會執行以下URI:
coolwallet://?action=getAccounts&callback=https%3A%2F%2Frelay.host%2F%3Fsession%3Dxxx&apiKey=ooo&source=JOYSO
然後Coolwallet應該將結果以JSON格式POST到callback URL
POST https://relay.host/?session=xxx
BODY
{
"result": ["0x8c03377931f3ca36154399c5516370bc6d54e81e"],
"error": null
}
或者有錯誤
{
"result": null,
"error": "錯誤訊息"
}
URI: coolwallet://?action=getAccounts
輸出: 錢包位址列表
URI範例
coolwallet://?action=getAccounts&callback=https%3A%2F%2Frelay.host%2F%3Fsession%3Dxxx&apiKey=ooo&source=JOYSO
回傳範例
{
"result": ["0x8c03377931f3ca36154399c5516370bc6d54e81e"],
"error": null
}
錯誤
{
"result": null,
"error": "錯誤訊息"
}
URI: coolwallet://?action=signMessage
輸入
參數 | 必填 | 說明 |
---|---|---|
from | O | 簽署人地址 |
data | O | 簽署內容 |
raw | Hash前的內容(data = keccak256(raw) , 參見簽署訊息格式)) |
- 最後進行簽署的內容應為
'\x19Ethereum Signed Message:\n' + data.length + data
- 例如 0xbbf0ab1e9bd8cff92628e7fa4a6044985df9399c8d3c7de6897d980b3e312734 的長度為32
輸出: 簽署後結果
URI範例
coolwallet://?action=signMessage&from=0x8c03377931f3ca36154399c5516370bc6d54e81e&data=0xbbf0ab1e9bd8cff92628e7fa4a6044985df9399c8d3c7de6897d980b3e312734&raw=0x04f062809b244e37e7fdc21d9409469c989c234200000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000b5e620f48000000000000000000000000000000000000000000000000000000000000005b8d85b50643f000a000500007d00dde12a12a6f67156e0da672be05c374e1b0a3e57&callback=https%3A%2F%2Frelay.host%2F%3Fsession%3Dxxx&apiKey=ooo&source=JOYSO
回傳範例
{
"result": "0x50d7441ad2e08c07cf296ea4bddee7c6930a0e593bb5a4cacd1901cb902f61787e28cfd4e112d0f944e107c066118e52999525cb964a2e6648fc399dadd3de901b",
"error": null
}
錯誤
{
"result": null,
"error": "錯誤訊息"
}
URI: coolwallet://?action=signTransaction
輸入
參數 | 必填 | 說明 |
---|---|---|
from | O | 發送者地址 |
to | 目標地址 | |
value | 傳送的ETH量 (wei) | |
gas | Gas limit | |
gasPrice | Gas price (wei) | |
data | 交易的Input data | |
nonce | Nonce |
輸出: 簽署後Raw Transaction
URI範例
coolwallet://?action=signTransaction&from=0x8c03377931f3ca36154399c5516370bc6d54e81e&to=0x7037734b180c44b7041a31666486f81f45860541&value=0xde0b6b3a7640000&gas=0x5208&gasPrice=0xee6b2800&nonce=0x141&data=0x1234&callback=https%3A%2F%2Frelay.host%2F%3Fsession%3Dxxx&apiKey=ooo&source=JOYSO
回傳範例
{
"result": "0xf86e827f738509502f900082c350947b0db0f1af5920977746c632d107b302b5d669da880354c86135f350008026a0f57dd7cc619adbb3fd57e07063b970d5bba48205baf073dbe67fa32c3ecc06bda079b8ce6d8c59d53ab3e6d081ce48c348593a18e2fc9993e72b4e2023c4c4355e",
"error": null
}
錯誤
{
"result": null,
"error": "錯誤訊息"
}
長度: 296字元
範例: 賣出 1 JOY @ 價格 0.0002
Data: 0x5b8295d57119fa365012a5075ba4dca8c70f39d575295c654dd8bbf41210a204
Raw: 04f062809b244e37e7fdc21d9409469c989c234200000000000000000000000000000000000000000000000000000000000f42400000000000000000000000000000000000000000000000000000b5e620f48000000000000000000000000000000000000000000000000000000000000005b8d85b50643f000a000500007d00dde12a12a6f67156e0da672be05c374e1b0a3e57
最終簽署: 0x91bd07011991e28a9a5460b7e84715c9a96d44d036354a5615a4441283a36cc9
解析
名稱 | 片段 | 說明 |
---|---|---|
JOYSO合約位址 | 04f062809b244e37e7fdc21d9409469c989c2342 | |
賣出的量 | 00000000000000000000000000000000000000000000000000000000000f4240 | 十進位1000000,JOY小數為6位,等值1 JOY |
買入的量 | 0000000000000000000000000000000000000000000000000000b5e620f48000 | 十進位200000000000000,ETH小數為18位,等值0.0002 ETH |
礦工費 | 000000000000000000000000000000000000000000000000000000000005b8d8 | 此範例為使用JOY支付。十進位375000,等值0.375 JOY |
Nonce | 5b50643f | 隨機亂數,Timestamp |
Taker手續費 | 000a | 十進位10,表示0.1% |
Maker手續費 | 000a | 十進位5,表示0.05% |
JOY報價 | 00007d0 | 當此欄位有值,表示使用JOY支付;否則為ETH。十進位2000,表示0.0002 |
買或賣 | 0 | 0表示賣出,1表示買入 |
代幣地址 | dde12a12a6f67156e0da672be05c374e1b0a3e57 | 此範例為JOY |
長度: 232字元
範例: 提取 1 JOY, 手續費 0.25 JOY
Data: 0x5b8295d57119fa365012a5075ba4dca8c70f39d575295c654dd8bbf41210a204
Raw: 04f062809b244e37e7fdc21d9409469c989c234200000000000000000000000000000000000000000000000000000000000b71b0000000000000000000000000000000000000000000000000000000000003d0905b51675d0000000000000001dde12a12a6f67156e0da672be05c374e1b0a3e57
最終簽署: 0x91bd07011991e28a9a5460b7e84715c9a96d44d036354a5615a4441283a36cc9
解析
名稱 | 片段 | 說明 |
---|---|---|
JOYSO合約位址 | 04f062809b244e37e7fdc21d9409469c989c2342 | |
提取的量 | 00000000000000000000000000000000000000000000000000000000000b71b0 | 十進位750000,JOY小數為6位,等值0.75 JOY |
礦工費 | 000000000000000000000000000000000000000000000000000000000003d090 | 此範例為使用JOY支付。十進位250000,等值0.25 JOY |
Nonce | 5b51675d | 隨機亂數,Timestamp |
未使用 | 000000000000000 | |
付款方式 | 1 | 0: ETH, 1: JOY, 2: 當前代幣 |
代幣地址 | dde12a12a6f67156e0da672be05c374e1b0a3e57 | 此範例為JOY |
格式: joyso{timestamp}
範例:
Data: 0x5b968b81acc08500deb338054a89687ee8b69423601b78281892a7dd835be1e4
Raw: 6a6f79736f31353332303830363833 (原文: joyso1532080683)
最終簽署: 0xe62e8bbca6278ea7b686fa6e6254916da289641ccd50c80076721d241013379b
格式: Signing this message proves to JOYSO you are in control of your account without giving JOYSO access to any sensitive information. Message ID: {timestamp}
範例:
Data: 0x5369676e696e672074686973206d6573736167652070726f76657320746f204a4f59534f20796f752061726520696e20636f6e74726f6c206f6620796f7572206163636f756e7420776974686f757420676976696e67204a4f59534f2061636365737320746f20616e792073656e73697469766520696e666f726d6174696f6e2e204d6573736167652049443a2031353430393830313335
Raw: 5369676e696e672074686973206d6573736167652070726f76657320746f204a4f59534f20796f752061726520696e20636f6e74726f6c206f6620796f7572206163636f756e7420776974686f757420676976696e67204a4f59534f2061636365737320746f20616e792073656e73697469766520696e666f726d6174696f6e2e204d6573736167652049443a2031353430393830313335 (原文: Signing this message proves to JOYSO you are in control of your account without giving JOYSO access to any sensitive information. Message ID: 1540980135)
最終簽署: 0x06a7ea7178d0b019bb27e8d06800f2042a9ee9565d35eb541836f2a7784b825f