Cat20 Split

api base

test url: https://test-api-proxy.ddpurse.com

main url: https://api.dotswap.app

通过以下接口可以拆分指定地址的 cat20 资产到不同的地

获取拆分cat20psbt

post
Header parameters
AuthorizationstringOptional

token

User-IdstringOptional
Body
tickstringRequired

tickName+冒号+tokenId

is_ofc_tokenbooleanRequired

是不是官方token(个人请默认填写false, 否则请联系官方加白名单)

is_average_splitbooleanRequired

是否平均拆分到原地址

split_numintegerRequired

拆分数量

user_addrstringRequired

当前用户地址

user_pubkeystringRequired

当前用户公钥

cat_20_output_to_splitstringRequired

txid+冒号+vout

token_addrstringRequired

如果选择官方token就需要填写

fee_rateintegerRequired
Responses
200

成功

application/json
post
/brc20swap/get_split_cat20_psbts
POST /brc20swap/get_split_cat20_psbts HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 220

{
  "tick": "text",
  "is_ofc_token": true,
  "is_average_split": true,
  "split_num": 1,
  "toinfos": [
    {
      "to_addr": "text",
      "to_amt": 1
    }
  ],
  "user_addr": "text",
  "user_pubkey": "text",
  "cat_20_output_to_split": "text",
  "token_addr": "text",
  "fee_rate": 1
}
{
  "code": 1,
  "msg": "text",
  "data": {
    "psbts": [
      {
        "psbt_base64": "text",
        "to_sign_inputs": [
          {
            "index": 1,
            "not_sign": true,
            "leaf_hash": "text",
            "final_script_witness_length": 1
          }
        ]
      }
    ],
    "leaf_script": "text",
    "control_block": "text",
    "leaf_version": 1,
    "total_fee": 1,
    "service_fee_fb": 1,
    "net_work_fee_fb": 1,
    "total_fee_cat20": 1,
    "service_fee_cat20": 1,
    "order_id": "text"
  }
}

拆个人的 cat20

{
  "tick": "dog:b1071ae617c66050d518587f67564885ca1a618b387a15f84001e3fa244ef3d6_0",
  "is_ofc_token": false,
  "user_addr": "bc1pxul8mg4fvx....cxej453h24smw03s0",
  "user_pubkey": "02d3ac7452920b1cc4....0a8c0aac6e3446e633a73ea63eee81",
  "cat_20_output_to_split": "08806ff819db249637a7c1cc762e4f9e29182d7dc658b7571f12c2b539106a1f:2",
  "token_addr": "bc1pxul8mg4fvx....cxej453h24smw03s0",
  "fee_rate": 9,
  "toinfos": [
    {
      "to_addr": "bc1pxrvq4n9ud.....587lf3xszyyczr",
      "to_amt": 5
    },
    {
      "to_addr": "bc1pxrvq4n9ud.....587lf3xszyyczr",
      "to_amt": 5
    },
    {
      "to_addr": "bc1pxrvq4n9ud.....587lf3xszyyczr",
      "to_amt": 5
    },
    {
      "to_addr": "bc1pxrvq4n9ud.....587lf3xszyyczr",
      "to_amt": 5
    },
    {
      "to_addr": "bc1pxrvq4n9ud.....587lf3xszyyczr",
      "to_amt": 5
    }
  ]
}

1、关于 cat_20_output_to_split,需要查询对应地址的对应 cat20 的 utxo,找到想拆分的 utxo,然后用对应 utxo 的 txId 和 outputIndex 进行拼接

查询地址参考(请替换 tokenIdOrTokenAddr 和 ownerAddrOrPkh)

拆官方的 cat20

如果你有使用官方的 cat20 充值的接口,那么你也可以使用这个接口拆分你充值进来的 cat20。

  • 首先调用充值接口 /create_deposit_cat20_psbtv2的时候,你可以设置参数not_split:true

  • 充值成功之后,/create_deposit_cat20_order_by_psbt会返回 receiver_addrtxid

这个时候你可以用如下参数来调用拆分接口

{
  // 这两个参数请默认写为true
  "is_ofc_token": true,
  "is_average_split": true,

  // 这是你用于充值的钱包
  "user_addr": "bc1psx048lgxx9qlgnw2yjn6vw7ndz07f5rdlfxraqpxkr84tqa7670sagd4k8",
  "user_pubkey": "03c22e2f276e66c24e515b24a0c6bcf53852b046b31bbaf98d3f3075c005729691",

  // 准备拆分的代币(和你充值的代币名称保持一致)
  "tick": "dog:b1071ae617c66050d518587f67564885ca1a618b387a15f84001e3fa244ef3d6_0",

  // 这个是充值接口返回的 txid + :1(:1是固定的)
  "cat_20_output_to_split": "3c92ae8ce3fd6377ac9316a28ded9ca5daef835dd3cf2613b8047c1ee9bbf530:1",

  // 这是充值接口返回的receiver_addr
  "token_addr": "bc1plsm7wgedgkguhk5xyllhyml2zstu0z7zs353hq7h6jlvu5puf4sqhc2l5t",

  // 数量请大于4
  "split_num": 5,

  "fee_rate": 9
}

发送拆分cat20psbt

post
Header parameters
AuthorizationstringOptional

token

User-IdstringOptional
Body
psbtsstring[]Required
其他参数和获取psbt接口一样stringRequired
Responses
200

成功

application/json
post
/brc20swap/save_split_cat20_psbts
POST /brc20swap/save_split_cat20_psbts HTTP/1.1
Host: 
Content-Type: application/json
Accept: */*
Content-Length: 65

{
  "psbts": [
    "text"
  ],
  "其他参数和获取psbt接口一样": "text"
}
{
  "code": 1,
  "msg": "text",
  "data": {
    "tx_id": "text"
  }
}

Last updated