- 创建钱包,设置支付密码
- 通过私钥导入钱包,设置支付密码
- 导出私钥,支付密码验证
- tt链和以太坊共用同一个账户钱包体系
- 目前实现了tt链和以太坊上的pala erc20代币相互之间的转移
- 用户在钱包页面操作跨链,前端调取后端两个接口,第一个是生成一笔跨链转账订单的接口,返回成功状态之后再调取发送跨链转账交易的接口
- 前端通过转账订单返回的订单号来拉取跨链转账的转账详情展示给用户
- 跨链转账需要扣除一定的pala作为转账的交易手续费,所以接收的pala会少于发起的pala数量
- 用户操作跨链转账的账户必须要有足够的eth或者tt作为发起交易的gas fee
- 用户可以在该钱包中实现以太坊上的usdt闪兑成以太坊上的pala代币
- 前端调取申请闪兑接口即可开启闪兑流程
- 前端通过返回的闪兑的订单号来拉取闪兑的进度展示给用户
- 前端拉取后端的token价格的接口,计算出闪兑的兑换比例
- 用户执行闪兑操作,账户中必须有足够的eth用于发送闪兑交易的gas fee
- POST
/tac/apply_order
{
"fromAddr":"0x67Adf250F70F6100d346cF8FE3af6DC7A2C23213",
"recipientAddr":"0x7AC954Ed6c2d96d48BBad405aa1579C828409f59",
"amount":"55.555",
"password":"123456",
"orderType":2
}
fromAddress
: pala代币转出地址recipientAddr
: pala代币接收地址amount
: 跨链转账数量,后面必须加上8个0password
: 地址对应的支付密码orderType
: 跨链转账的类型,为1表示从以太坊的pala转到tt链的pala, 为2表示从tt链的pala转到以太坊上的pala
// 成功返回示例,会返回订单号给前端
{
"status": 200,
"data": {
"orderId": 5
},
"msg": "success",
"error": ""
}
- GET
/tac/order/:id
id
: 订单id
// 接口调用成功
{
"status": 200,
"data": {
"from_addr": "0x67adf250f70f6100d346cf8fe3af6dc7a2c23213",
"recipient_addr": "0x7ac954ed6c2d96d48bbad405aa1579c828409f59",
"amount": "55.555",
"order_type": 1,
"state": 0
},
"msg": "success",
"error": ""
}
from_addr
: 跨链pala代币转出地址recipient_addr
: pala代币接收地址amount
: 转账金额order_type
: 订单类型,为1表示从以太坊的pala转到tt链的pala, 为2表示从tt链的pala转到以太坊上的palastate
: 订单状态,为0表示订单进行中,为1表示订单完成,为2表示订单失败,为3表示订单超时
- POST
/tac/send_tac_tx
{
"address": "0x67Adf250F70F6100d346cF8FE3af6DC7A2C23213",
"password":"123456",
"amount":"55.555",
"tac_order_id": 11,
"order_type":2
}
- address: 钱包地址
- password: 钱包支付密钥
- amount: 跨链金额
- order_type: 跨链类型。1表示从eth_pala转到tt_pala,2则相反
- tac_order_id:跨链转账订单返回来的订单id
// 返回交易hash
{
"status": 200,
"data": {
"tx_hash": "0x9687dc46485f0be3791d8054c39a8d3b9f10ac108f7d8157494ae0391e671081"
},
"msg": "success",
"error": ""
}
- POST
/tac/create_wallet
{
"password":"123456"
}
- password: 用户支付时的密码,最小6位,最大12位
// 返回地址address,需要前端保存到localstorage中,要求用户需要备份地址。
{
"status": 200,
"data": {
"address": "0xb86ebA9f29Fcc6cA8dE202889111dC1c6BEdDf16"
},
"msg": "success",
"error": ""
}
- POST /tac/lead_wallet
{
"private":"90909E90903DCCF0A03D9D1BE998E161532A264A959C8989158B6C9ACA92H33C",
"password":"12345678"
}
- private:导入的私钥
- password:账户支付密码设置
// 返回导入private对应的address,前端需要把address 存入localstorage
{
"status": 200,
"data": {
"address": "0x67Adf250F70F6100d346cF8FE3af6DC7A2C99999"
},
"msg": "success",
"error": ""
}
- POST /tac/export_private
{
"address":"0xb86ebA9f29Fcc6cA8dE202889111dC1c6BEdDf16",
"password":"123456"
}
- address: 钱包地址
- password: 支付密码
// 成功返回示例
{
"status": 200,
"data": {
"private": "F234120DE07D7F5CE27EAA1D7B954F55BDC49E6C3B2B19FB78C5000A191CEE4F"
},
"msg": "success",
"error": ""
}
// password失败返回示例
{
"status": 40006,
"data": null,
"msg": "导出私钥失败",
"error": "输入的密码有误"
}
// address有误的返回示例
{
"status": 40006,
"data": null,
"msg": "导出私钥失败",
"error": "record not found"
}
- POST /tac/modify_password
{
"address":"0x7AC954Ed6c2d96d48BBad405aa1579C828409f59",
"old_password":"12345678",
"new_password":"123456789"
}
- address: 修改密码地址
- old_password: 旧密码
- new_password: 新密码
// 成功情况
{
"status": 200,
"data": null,
"msg": "success",
"error": ""
}
// 失败情况1. 旧密码不正确
{
"status": 40014,
"data": null,
"msg": "modify password error",
"error": "旧的密码验证不通过"
}
// 失败情况2. address不存在
{
"status": 40014,
"data": null,
"msg": "modify password error",
"error": "record not found"
}
- POST /tac/check_password
{
"address":"0x9F500F1BB530BAA6BBB280998d15b8FBdDaCDA15",
"password":"123456"
}
- address: 地址
- password: 密码
// 校验成功请款,data返回布尔值的true
{
"status": 200,
"data": true,
"msg": "success",
"error": ""
}
// 校验失败情况,返回false
{
"status": 200,
"data": false,
"msg": "success",
"error": ""
}
// 输入的地址有误的情况
{
"status": 40021,
"data": null,
"msg": "check password error",
"error": "地址不存在"
}
- POST /tac/exchange/eth_usdt_pala
{
"operate_address":"0x7AC954Ed6c2d96d48BBad405aa1579C828409f59",
"password":"123456",
"from_token_amount":"500.00",
"to_token_amount":"100.00",
"trade_price":"6.771"
}
- operate_address: 需要闪兑的地址,也是用户的钱包地址
- password: 钱包的支付密码
- from_token_amount: usdt的兑换amount
- to_token_amount: 兑换成pala的amount
- trade_price: 闪兑的价格
{
"status": 200,
"data": {
"orderId": 5
},
"msg": "success",
"error": ""
}
- POST /tac/get_balance
{
"address":"0x67Adf250F70F6100d346cF8FE3af6DC7A2C23213"
}
{
"status": 200,
"data": {
"tt_balance": "7478703.390000",
"eth_balance": "1900.000000",
"decimal": 18
},
"msg": "success",
"error": ""
}
- POST /tac/get_token_balance
{
"address":"0x7AC954Ed6c2d96d48BBad405aa1579C828409f59"
}
{
"status": 200,
"data": {
"tt_pala_balance": "1000.00000",
"eth_pala_balance": "101000.00899",
"eth_usdt_balance": "35000.000000",
"usdt_decimal": 6,
"pala_decimal": 8
},
"msg": "success",
"error": ""
}
- tt_pala_balance: tt链上pala的余额
- eth_pala_balance: eth链上pala的余额
- eth_usdt_balance: eth链上usdt的余额
- usdt_decimal: usdt小数位数
- pala_decimal: pala小数位数
- GET /tac/get_eth_pala_price
{
"status": 200,
"data": {
"pair": "PALA_USDT",
"trade_price": "6.31400000"
},
"msg": "success",
"error": ""
}
- GET /tac/get_eth_price
{
"status": 200,
"data": {
"pair": "ETH_USDT",
"trade_price": "213.69"
},
"msg": "success",
"error": ""
}
- POST /tac/exchange/get_flash_orders
{
"page":1,
"limit":5,
"address":"0x7AC954Ed6c2d96d48BBad405aa1579C828409f59"
}
- page: 页数,从1开始
- limit: 每一页拉取数量
- address: 地址
{
"status": 200,
"data": {
"total": 3,
"list": [
{
"created_at": 1590045304,
"amount": "0.000777",
"state": 1
},
{
"created_at": 1590045232,
"amount": "10000000000.000000",
"state": 1
},
{
"created_at": 1590045155,
"amount": "10000000000.000000",
"state": 1
}
]
},
"msg": "success",
"error": ""
}
- total: 总数
- created_at:创建时间
- amount: 闪兑的数量
- state: 订单状态,0. pending,1. success 2. failed
- POST /tac/get_tac_orders
{
"order_type":1,
"address":"0x67adf250f70f6100d346cf8fe3af6dc7a2c23213",
"page":1,
"limit":5
}
- order_type: 订单类型,orderType == 1 表示拉取以太坊跨链转账到tt链的订单,为2则相反
- address: 对应地址
- page:分页数,从1开始
- limit:每一次拉取的条数
{
"status": 200,
"data": {
"total": 2,
"list": [
{
"created_at": 1590044696,
"amount": "0.000007",
"state": 1
},
{
"created_at": 1590044689,
"amount": "0.000006",
"state": 0
}
]
},
"msg": "success",
"error": ""
}
- total: 总数
- created_at: 订单创建时间
- amount: 跨链pala的数量
- state: 订单状态,0. pending,1. success 2. failed
- POST /tac/get_eth_pala_receive
{
"address":"0x9d7bc48d1c7a42b5fa9e070b4e301d2445bea926",
"page":1,
"limit":3
}
{
"status": 200,
"data": [
{
"from": "0x65b1c87aa01c82c1d15adcda7e21f3187594b2c9",
"to": "0x9d7bc48d1c7a42b5fa9e070b4e301d2445bea926",
"amount": "4783.880000",
"time_at": 1590104685
},
{
"from": "0x65b1c87aa01c82c1d15adcda7e21f3187594b2c9",
"to": "0x9d7bc48d1c7a42b5fa9e070b4e301d2445bea926",
"amount": "88888.888888",
"time_at": 1590104681
},
],
"msg": "success",
"error": ""
}
// 记录为空的情况
{
"status": 200,
"data": [],
"msg": "success",
"error": ""
}
- POST /tac/get_eth_usdt_receive
{
"address":"0xa416d8034811e944ac9ddf759c6d6dcf0a985d5a",
"page":1,
"limit":3
}
{
"status": 200,
"data": [
{
"from": "0x629155a6f95a91ce6eb3548768fa37441f83d26d",
"to": "0xa416d8034811e944ac9ddf759c6d6dcf0a985d5a",
"amount": "18.658000",
"time_at": 1590230722
},
{
"from": "0x629155a6f95a91ce6eb3548768fa37441f83d26d",
"to": "0xa416d8034811e944ac9ddf759c6d6dcf0a985d5a",
"amount": "18.658000",
"time_at": 1590153899
},
{
"from": "0x629155a6f95a91ce6eb3548768fa37441f83d26d",
"to": "0xa416d8034811e944ac9ddf759c6d6dcf0a985d5a",
"amount": "18.658000",
"time_at": 1590091627
}
],
"msg": "success",
"error": ""
}
- POST /tac/get_eth_receive
{
"address":"0x49228289b27dbe2b0d42e63ca14693ddebe86910",
"page":1,
"limit":100
}
{
"status": 200,
"data": [
{
"from": "0x58a886deed780a38a9ffbbf26fb4dcc7cb77b7c9",
"to": "0x49228289b27dbe2b0d42e63ca14693ddebe86910",
"amount": "0.300000",
"time_at": 1589181727
},
{
"from": "0x5b82936039e25e02d9278bb9d3e5b5573823bc32",
"to": "0x49228289b27dbe2b0d42e63ca14693ddebe86910",
"amount": "0.048000",
"time_at": 1589003238
}
],
"msg": "success",
"error": ""
}
- POST /tac/get_gas_fee
{
"chain_tag": 17
}
- chain_tag: 链的标识,17代表以太坊的链,77代表thundercore链
{
"status": 200,
"data": {
"gas_fee": "0.000120"
},
"msg": "success",
"error": ""
}
- POST /tac/encrypto_private
{
"private":"11110B440C3FC1CCFF8B3339D41850C5B9A3D712F804FA3EE1CDD8F311111111"
}
{
"status": 200,
"data": "0x144ce7cafee21e556ade38e8a9f011ac3fa231cf83f798417c0c85de795ddc10494914d66877d1bda6fcbd190c7f3f9b",
"msg": "success",
"error": ""
}
- data: 返回aes对称加密之后的私钥。用于配置在正式环境的跨链转账和闪兑的中间地址的私钥上,避免了服务器上有明文私钥
- GET /tac/get_tac_charge
{
"status": 200,
"data": {
"to_tt_charge": "1.00000000",
"to_eth_charge": "3.00000000"
},
"msg": "success",
"error": ""
}
- to_tt_charge: 以太坊上的pala跨链转到tt链上的pala需要的手续费
- to_eth_charge: tt链上的pala跨链转到以太坊上的pala需要的手续费
- POST /tac/modify_tac_charge
{
"to_tt_charge": "1.1",
"to_eth_charge": "0.5"
}
- to_tt_charge: 以太坊上的pala跨链转到tt链上的pala需要的手续费
- to_eth_charge: tt链上的pala跨链转到以太坊上的pala需要的手续费
{
"status": 200,
"data": null,
"msg": "success",
"error": ""
}
- GET /tac/get_pala_price_change_rate
{
"status": 200,
"data": 1.01,
"msg": "success",
"error": ""
}
- POST /tac/modify_pala_price_change_rate
{
"rate": "1.1"
}
- rate: 倍数表示法;1.01表示上浮1%, 1.1表示上浮10%
{
"status": 200,
"data": null,
"msg": "success",
"error": ""
}
- GET /tac/get_flash_total_gas_fee
{
"status": 200,
"data": "0.000360",
"msg": "",
"error": ""
}
- GET /tac/get_tac_total_gas_fee
{
"status": 200,
"data": "0.000360",
"msg": "",
"error": ""
}
- GET /tac/get_flash_pala_usdt_total
{
"status": 200,
"data": {
"pala_total": "24.000000",
"usdt_total": "2400.000000"
},
"msg": "success",
"error": ""
}
- POST /tac/send_eth_pala_transfer
{
"from_address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"password":"123456",
"to_address":"0x415979DC0266fd94A3CB90a04EC28853FCeB1A34",
"amount":"200.78"
}
- from_address: 发送地址
- password: 发送地址的支付密码
- to_address:接收地址
- amount:发送数量
{
"status": 200,
"data": {
"tx_hash": "0xf78d3c16106214a88e670656bfe8aa7bf95113238a04747ccc3f0ece55c570ae"
},
"msg": "success",
"error": ""
}
// 返回错误
{
"status": 40022,
"data": null,
"msg": "send pala transfer failed",
"error": "pala转账余额不足;转账amount: 20000000000000, pala余额:0, address: 0x59375A522876aB96B0ed2953D0D3b92674701Cc2"
}
- POST /tac/send_tt_pala_transfer
{
"from_address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"password":"123456",
"to_address":"0x415979DC0266fd94A3CB90a04EC28853FCeB1A34",
"amount":"200.78"
}
- from_address: 发送地址
- password: 发送地址的支付密码
- to_address:接收地址
- amount:发送数量
{
"status": 200,
"data": {
"tx_hash": "0xf78d3c16106214a88e670656bfe8aa7bf95113238a04747ccc3f0ece55c570ae"
},
"msg": "success",
"error": ""
}
// 返回错误
{
"status": 40022,
"data": null,
"msg": "send pala transfer failed",
"error": "pala转账余额不足;转账amount: 20000000000000, pala余额:0, address: 0x59375A522876aB96B0ed2953D0D3b92674701Cc2"
}
- POST /tac/send_eth_transfer
{
"from_address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"password":"123456",
"to_address":"0x415979DC0266fd94A3CB90a04EC28853FCeB1A34",
"amount":"0.11"
}
- from_address: 发送地址
- password: 发送地址的支付密码
- to_address:接收地址
- amount:发送数量
{
"status": 200,
"data": {
"tx_hash": "0xf78d3c16106214a88e670656bfe8aa7bf95113238a04747ccc3f0ece55c570ae"
},
"msg": "success",
"error": ""
}
// 返回错误
{
"status": 40023,
"data": null,
"msg": "send main coin transfer failed",
"error": "主网币 转账余额不足;转账amount: 22222222000000000000000000, 余额:701071686600000000, address: 0x59375A522876aB96B0ed2953D0D3b92674701Cc2"
}
- POST /tac/send_tt_transfer
{
"from_address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"password":"123456",
"to_address":"0x415979DC0266fd94A3CB90a04EC28853FCeB1A34",
"amount":"0.0001"
}
- from_address: 发送地址
- password: 发送地址的支付密码
- to_address:接收地址
- amount:发送数量
{
"status": 200,
"data": {
"tx_hash": "0xaddc1fd42966cd918e6e5fc512a21e7a5620ff2e565b7ab453dd4356cdd3eccb"
},
"msg": "success",
"error": ""
}
// 返回错误
{
"status": 40023,
"data": null,
"msg": "send main coin transfer failed",
"error": "主网币 转账余额不足;转账amount: 22222222000000000000000000, 余额:701071686600000000, address: 0x59375A522876aB96B0ed2953D0D3b92674701Cc2"
}
- POST /tac/send_eth_usdt_transfer
{
"from_address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"password":"123456",
"to_address":"0x415979DC0266fd94A3CB90a04EC28853FCeB1A34",
"amount":"100"
}
- from_address: 发送地址
- password: 发送地址的支付密码
- to_address:接收地址
- amount:发送数量
{
"status": 200,
"data": {
"tx_hash": "0xe25b07f0b2df30deb2a698ba926e3818aa87a1eeb8eb8085c1dd87ebdd70c30d"
},
"msg": "success",
"error": ""
}
// 返回错误
{
"status": 40024,
"data": null,
"msg": "send main coin transfer failed",
"error": "主网币 转账余额不足;转账amount: 22222222000000000000000000, 余额:701071686600000000, address: 0x59375A522876aB96B0ed2953D0D3b92674701Cc2"
}
- GET /tac/get_app_version
{
"status": 200,
"data": {
"version": "2.1.1",
"wgt_url": "http://aaa.kk.com/wallet.wget",
"pkg_url": "http://aaa.kk.com/wallet.apk"
},
"msg": "success",
"error": ""
}
- GET /tac/update?version=3.2.2
// update为false则表示不需要更新
{
"status": 200,
"data": {
"update": false,
"version": "",
"wgt_url": "",
"pkg_url": ""
},
"msg": "success",
"error": ""
}
// 大版本更新 http://127.0.0.1:3030/tac/update?version=1.2.2
{
"status": 200,
"data": {
"update": true,
"version": "2.1.1",
"wgt_url": "",
"pkg_url": "http://aaa.kk.com/wallet.apk"
},
"msg": "success",
"error": ""
}
// 小版本更新 http://127.0.0.1:3030/tac/update?version=2.0.0
{
"status": 200,
"data": {
"update": true,
"version": "2.1.1",
"wgt_url": "http://aaa.kk.com/wallet.wget",
"pkg_url": ""
},
"msg": "success",
"error": ""
}
- POST /tac/set_app_version
{
"version":"2.1.1",
"wgt_url":"http://aaa.kk.com/wallet.wget",
"pkg_url":"http://aaa.kk.com/wallet.apk"
}
- version: 设置发布的最新版本号
- wgt_url:发布的补丁保存下载链接(七牛云上)
- pkg_url:发布的大版本整包更新保存的下载链接(七牛云上) 注:wgt_url和pkg_url可以任意填一个,也可以同时填写
{
"status": 200,
"data": null,
"msg": "success",
"error": ""
}
- POST /tac/get_eth_pala_send_records
{
"address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"page": 1,
"limit":5
}
{
"status": 200,
"data": {
"total": 1,
"list": [
{
"created_at": 1590901424,
"amount": "200000.000000",
"state": 1
}
]
},
"msg": "success",
"error": ""
}
- POST /tac/get_tt_pala_send_records
{
"address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"page": 1,
"limit":5
}
{
"status": 200,
"data": {
"total": 1,
"list": [
{
"created_at": 1590901509,
"amount": "10.000000",
"state": 1
}
]
},
"msg": "success",
"error": ""
}
- POST /tac/get_eth_send_records
{
"address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"page": 1,
"limit":5
}
{
"status": 200,
"data": {
"total": 2,
"list": [
{
"created_at": 1590907272,
"amount": "0.000100",
"state": 0
},
{
"created_at": 1590901672,
"amount": "0.00",
"state": 1
}
]
},
"msg": "success",
"error": ""
}
- POST /tac/get_tt_send_records
{
"address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"page": 1,
"limit":5
}
{
"status": 200,
"data": {
"total": 2,
"list": [
{
"created_at": 1590907260,
"amount": "0.001000",
"state": 1
},
{
"created_at": 1590901765,
"amount": "0.00",
"state": 1
}
]
},
"msg": "success",
"error": ""
}
- POST /tac/get_eth_usdt_send_records
{
"address":"0x59375A522876aB96B0ed2953D0D3b92674701Cc2",
"page": 1,
"limit":5
}
{
"status": 200,
"data": {
"total": 1,
"list": [
{
"created_at": 1590901832,
"amount": "1.000000",
"state": 1
}
]
},
"msg": "success",
"error": ""
}