DeBox Bot Blockchain Buttons (button3)
DeBox supports two ways to start wallet signing and on-chain transactions: an IM blockchain button
inside a chat, or a custom H5/DApp page. This page explains how to choose between them, defines the
responsibility boundary of an IM blockchain button, and preserves the source-aligned button3
parameters and complete main.go example.
Open the button3 Bot profile in the DeBox App to try the IM blockchain-button flow.
Start the demo
- Open the button3 Bot profile in the DeBox App and enter the chat.
- Tap the command button to the left of the input field, or enter
/in the input field, to open the command list. - Select
/startfrom the command list. - The Bot sends the available demo buttons. Select the signing or transaction action you want to try.

Step 1. Tap the command button. Entering / in the input field opens the same list.

Step 2. Select /start to display the demo buttons.
1. Choose an on-chain interaction method
| Method | Best for | Development model |
|---|---|---|
| IM blockchain button | A single signing, authorization, payment, or contract action directly in chat | DeBox provides the supported button and native wallet-confirmation flow; the developer supplies the request parameters. |
| H5 / DApp | Forms, quotes, risk notices, calculations, multi-step actions, and order-management interfaces | The developer builds the page and business logic, then uses standard Web3.js with the injected wallet provider. |
Use an IM blockchain button when one click can be represented by a supported wallet request. Use an H5/DApp when the user needs to review or enter more information before signing or paying.
1.1 Two ways to open DeBox Swap
DeBox supports two ways to open the native Swap flow:
- IM blockchain button: use the general
debox://wallet/requestroute with a JSON-RPC wallet request. In addition to signing, transfers, and contract calls, a request withmethod: "swap"can open the native DeBox Swap. - Swap modal Deep Link: use the dedicated
debox://rn/trade/swap/modalroute with URL query parameters to prefill the chain, token to sell, token to buy, and amount. The link can be sent as a Bot URL button or rich-text link and supportsrefGidfor group-channel revenue-sharing attribution.
| Method | Request format | Best for |
|---|---|---|
wallet/request + method: "swap" | JSON-RPC request | IM blockchain buttons and Swap requests built in the wallet-request format |
trade/swap/modal | URL query parameters | URL buttons, rich-text links, prefilled Swap, and revenue-sharing channel attribution |
Both methods open DeBox Swap, but their request formats and use cases differ. refGid is the
group-channel attribution parameter for the Swap modal Deep Link. Do not add it directly to the
wallet/request JSON-RPC request unless the platform explicitly supports that format.
See DeBox App Deep Links for the complete Swap modal link and parameter reference.
2. How an IM blockchain button works
The button uses the supported debox://wallet/request route and carries a JSON-RPC wallet request in
its callback data.
| Responsibility | What it includes |
|---|---|
| DeBox client | Render the supported button format, handle the click, open the native DeBox wallet confirmation, and ask the wallet to sign or broadcast after the user approves. |
| Bot / developer | Choose the button text and supported presentation options; build and validate the JSON-RPC method, chain ID, addresses, value, and ABI-encoded data; resolve any placeholders before sending the button. |
The runtime flow is:
Bot sends an IM blockchain button
→ User selects the button
→ DeBox opens the native wallet confirmation
→ User approves or rejects the request
→ The wallet signs the message or broadcasts the transaction
A simplified transaction request looks like this:
{
"jsonrpc": "2.0",
"id": 104,
"method": "eth_sendTransaction",
"params": [
{
"chainId": "0x38",
"from": "0xUSER_ADDRESS",
"to": "0xTARGET_OR_CONTRACT_ADDRESS",
"data": "0xABI_ENCODED_CALLDATA",
"value": "0x0"
}
]
}
For a native-token payment, put the amount in value. For a token transfer or contract call, encode
the method and amount in data and normally keep value at 0x0.
In the bundled button3 sample, selfAddress is a temporary placeholder. The Bot code replaces it
with user.Address through escapeAllStr before sending the button. Do not rely on the DeBox client
to perform that sample-specific replacement.
3. button3 parameters (source-aligned)
These payload strings are defined in main.go and bound to button CallbackData on /start:
eth_getBalanceStrpersonal_signStreth_signTypedData_v4Streth_sendTransactionStrNativeeth_sendTransactionStrTokeneth_sendTransactionApproveStrsendTransactionStrTransferFromsendTransactionStrMintsendTransactionStrSwapsendTransactionStrDeploy
Replacement rules (exact source behavior):
selfAddress-> current user wallet addressbotAddress-> bot wallet address (some calldata usesbotAddress[2:])- removes spaces/newlines/tabs via
escapeAllStr
4. main.go (verbatim)
package main
import (
"context"
"log"
"strings"
"github.com/debox-pro/debox-chat-go-sdk/boxbotapi"
)
var (
// Button texts
homeInfoContent = "home content"
eth_getBalance = "查账户余额"
// eth_gasPrice = "查gas费"
personal_sign = "personal_sign"
eth_signTypedData_v4 = "eth_signTypedData_v4"
eth_sendTransaction_native = "原生币转账"
eth_sendTransaction_token_approve = "Approve授权支付"
eth_sendTransaction_token_TransferFrom = "第三方授权转账TransferFrom"
eth_sendTransaction_Mint = "Mint"
eth_sendTransaction_token = "合约币转账"
eth_sendTransaction_swap = "swap"
eth_sendTransaction_deploy = "合约部署"
walletRequest = "debox://wallet/request"
bot *boxbotapi.BotAPI
// Keyboard layout for the second menu. Two buttons, one per row
homeMenuMarkup = boxbotapi.NewInlineKeyboardMarkup(
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_getBalance, walletRequest, eth_getBalance, "#21C161"),
),
// boxbotapi.NewInlineKeyboardRow(
// boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_gasPrice, walletRequest, eth_gasPrice, "#21C161"),
// ),
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", personal_sign, walletRequest, personal_sign, "#21C161"),
),
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_signTypedData_v4, walletRequest, eth_signTypedData_v4, "#21C161"),
),
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_native, walletRequest, eth_sendTransaction_native, "#21C161"),
),
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_token, walletRequest, eth_sendTransaction_token, "#21C161"),
),
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_swap, walletRequest, eth_sendTransaction_swap, "#21C161"),
),
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_token_approve, walletRequest, eth_sendTransaction_token_approve, "#21C161"),
),
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_token_TransferFrom, walletRequest, eth_sendTransaction_token_TransferFrom, "#21C161"),
),
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_Mint, walletRequest, eth_sendTransaction_Mint, "#21C161"),
),
// boxbotapi.NewInlineKeyboardRow(
// boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_token, walletRequest, eth_sendTransaction_token, "#21C161"),
// ),
// boxbotapi.NewInlineKeyboardRow(
// boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_swap, walletRequest, eth_sendTransaction_swap, "#21C161"),
// ),
boxbotapi.NewInlineKeyboardRow(
boxbotapi.NewInlineKeyboardButtonDataWithColor("", eth_sendTransaction_deploy, walletRequest, eth_sendTransaction_deploy, "#21C161"),
),
)
)
func main() {
var err error
boxbotapi.MessageListener = true
boxbotapi.Debug = true
bot, err = boxbotapi.NewBotAPI("", "")
if err != nil {
// Abort if something is wrong
log.Panic(err)
}
// Set this to true to log all interactions with debox servers
u := boxbotapi.NewUpdate(0)
u.Timeout = 30
// Create a new cancellable background context. Calling `cancel()` leads to the cancellation of the context
ctx := context.Background()
// ctx, cancel := context.WithCancel(ctx)
// `updates` is a golang channel which receives debox updates
updates := bot.GetUpdatesChan(u)
// Pass cancellable context to goroutine
go receiveUpdates(ctx, updates)
// Tell the user the bot is online
log.Println("Start listening for updates. Press enter to stop")
//new stop
select {}
}
func receiveUpdates(ctx context.Context, updates boxbotapi.UpdatesChannel) {
// `for {` means the loop is infinite until we manually stop it
for {
select {
// stop looping if ctx is cancelled
case <-ctx.Done():
return
// receive update from channel and then handle it
case update := <-updates:
handleUpdate(update)
}
}
}
func handleUpdate(update boxbotapi.Update) {
switch {
// Handle messages
case update.Message != nil:
handleMessage(update.Message)
break
// Handle button clicks
case update.CallbackQuery != nil:
handleButton(update.CallbackQuery)
break
}
}
func handleMessage(message *boxbotapi.Message) {
user := message.From
text := message.Text
botAddress := bot.Self.Address
if user == nil {
return
}
// Print to console
log.Printf("%s wrote %s", user.Name, text)
var err error
if len(text) > 0 {
msg := boxbotapi.NewMessage(message.Chat.ID, message.Chat.Type, message.Text)
msg.ParseMode = boxbotapi.ModeHTML
if text == "/start" {
msg.Text = homeInfoContent
msg.ReplyMarkup = homeMenuMarkup
var eth_getBalanceStr = `{
"jsonrpc": "2.0",
"id": 101,
"method": "eth_getBalance",
"params": [
{ "chainId": "0x38" },
"selfAddress",
"latest"
]
}`
//hexString := hex.EncodeToString(byteData)
var personal_signStr = `{
"jsonrpc": "2.0",
"id": 102,
"method": "personal_sign",
"params": [
{ "chainId": "0x38" },
"0x506c65617365207369676e2074686973206d65737361676520746f20636f6e6669726d20796f7572206964656e746974792e",
"selfAddress"
]
}`
//typedata_v4
// 使用 any 类型代替 interface{}
var eth_signTypedData_v4Str = `{
"jsonrpc": "2.0",
"id": 103,
"method": "eth_signTypedData_v4",
"params": [
"selfAddress",
{
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Person": [
{
"name": "name",
"type": "string"
},
{
"name": "wallet",
"type": "address"
}
],
"Mail": [
{
"name": "from",
"type": "Person"
},
{
"name": "to",
"type": "Person"
},
{
"name": "contents",
"type": "string"
}
]
},
"primaryType": "Mail",
"domain": {
"name": "Ether Mail",
"version": "1",
"chainId": 1,
"verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
},
"message": {
"from": {
"name": "Cow",
"wallet": "selfAddress"
},
"to": {
"name": "Bob",
"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
},
"contents": "Hello, Bob!"
}
}
]
}`
var eth_sendTransactionStrNative = `{
"jsonrpc": "2.0",
"id": 104,
"method": "eth_sendTransaction",
"params": [
{
"chainId": "0x38",
"to": "botAddress",
"from": "selfAddress",
"gas": "0x76c0",
"value": "0x38D7EA4C68000",
"data": "0x",
"gasPrice": "0x4a817c800"
}
]
}`
var eth_sendTransactionStrToken = `{
"jsonrpc": "2.0",
"id": 105,
"method": "eth_sendTransaction",
"params": [
{
"chainId": "0x38",
"from": "selfAddress",
"to": "0x6386Adc4BC9c21984E34fD916BB349dD861742af",
"value": "0x0",
"data": "0xa9059cbb000000000000000000000000botAddress0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"gas": "0x76c0",
"gasPrice": "0x4a817c800"
}
]
}`
var eth_sendTransactionApproveStr = `{
"jsonrpc": "2.0",
"id": 106,
"method": "eth_sendTransaction",
"params": [
{
"chainId": "0x38",
"from": "selfAddress",
"to": "0x6386Adc4BC9c21984E34fD916BB349dD861742af",
"gas": "0xb89b",
"gasPrice": "0x5d27a277",
"value": "0x0",
"data": "0x095ea7b3000000000000000000000000botAddress0000000000000000000000000000000000000000000000000de0b6b3a7640000"
}
]
}`
var sendTransactionStrTransferFrom = `{
"jsonrpc": "2.0",
"id": 106,
"method": "eth_sendTransaction",
"params": [
{
"from": "selfAddress",
"chainId":"0x38",
"data": "0x23b872dd000000000000000000000000cba3fce9d49ce5d7870443f324a8dd56a5788bfc0000000000000000000000006c663ff4b23ba3452e5ad1ad0c567e54b5ceee2e0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"gas": "0xad12",
"gasPrice": "0x596c5e37",
"to": "0x6386Adc4BC9c21984E34fD916BB349dD861742af",
"value": "0x0"
}
]
}`
var sendTransactionStrMint = `{
"jsonrpc": "2.0",
"id": 106,
"method": "eth_sendTransaction",
"params": [
{
"chainId":"0xa",
"from": "selfAddress",
"data": "0x3b4b1381000000000000000000000000000000000000000000000000000000000000000a",
"gas": "0x5135c",
"gasPrice": "0x18df9",
"to": "0x98c56f0903d1cb0c7eaedb91fb9d58409bbb1fbe",
"value": "0x0"
}
]
}`
var sendTransactionStrSwap = `{
"jsonrpc": "2.0",
"id": 106,
"method": "swap",
"params": [
{
"fromAddress": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
"toAddress": "0x6386Adc4BC9c21984E34fD916BB349dD861742af",
"fromChainId": "0x38",
"toChainId": "0x38"
}
]
}`
var sendTransactionStrDeploy = `{
"id": 4218609415,
"jsonrpc": "2.0",
"method": "eth_sendTransaction",
"params": [
{
"chainId":"0x38",
"from": "selfAddress",
"data":"0x60806040523480156200001157600080fd5b506040518060400160405280600c81526020017f54657374446170704e46547300000000000000000000000000000000000000008152506040518060400160405280600381526020017f54444e000000000000000000000000000000000000000000000000000000000081525081600090816200008f919062000324565b508060019081620000a1919062000324565b5050506200040b565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806200012c57607f821691505b602082108103620001425762000141620000e4565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b600060088302620001ac7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826200016d565b620001b886836200016d565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b600062000205620001ff620001f984620001d0565b620001da565b620001d0565b9050919050565b6000819050919050565b6200022183620001e4565b6200023962000230826200020c565b8484546200017a565b825550505050565b600090565b6200025062000241565b6200025d81848462000216565b505050565b5b8181101562000285576200027960008262000246565b60018101905062000263565b5050565b601f821115620002d4576200029e8162000148565b620002a9846200015d565b81016020851015620002b9578190505b620002d1620002c8856200015d565b83018262000262565b50505b505050565b600082821c905092915050565b6000620002f960001984600802620002d9565b1980831691505092915050565b6000620003148383620002e6565b9150826002028217905092915050565b6200032f82620000aa565b67ffffffffffffffff8111156200034b576200034a620000b5565b5b62000357825462000113565b6200036482828562000289565b600060209050601f8311600181146200039c576000841562000387578287015190505b62000393858262000306565b86555062000403565b601f198416620003ac8662000148565b60005b82811015620003d657848901518255600182019150602085019450602081019050620003af565b86831015620003f65784890151620003f2601f891682620002e6565b8355505b6001600288020188555050505b505050505050565b612be6806200041b6000396000f3fe608060405234801561001057600080fd5b50600436106100f45760003560e01c806342842e0e11610097578063a22cb46511610066578063a22cb46514610283578063b88d4fde1461029f578063c87b56dd146102bb578063e985e9c5146102eb576100f4565b806342842e0e146101e95780636352211e1461020557806370a082311461023557806395d89b4114610265576100f4565b8063081812fc116100d3578063081812fc14610165578063095ea7b31461019557806323b872dd146101b15780633b4b1381146101cd576100f4565b80629a9b7b146100f957806301ffc9a71461011757806306fdde0314610147575b600080fd5b61010161031b565b60405161010e91906119ac565b60405180910390f35b610131600480360381019061012c9190611a33565b61032c565b60405161013e9190611a7b565b60405180910390f35b61014f61040e565b60405161015c9190611b26565b60405180910390f35b61017f600480360381019061017a9190611b74565b6104a0565b60405161018c9190611be2565b60405180910390f35b6101af60048036038101906101aa9190611c29565b6104e6565b005b6101cb60048036038101906101c69190611c69565b6105fd565b005b6101e760048036038101906101e29190611b74565b61065d565b005b61020360048036038101906101fe9190611c69565b6106ac565b005b61021f600480360381019061021a9190611b74565b6106cc565b60405161022c9190611be2565b60405180910390f35b61024f600480360381019061024a9190611cbc565b610752565b60405161025c91906119ac565b60405180910390f35b61026d610809565b60405161027a9190611b26565b60405180910390f35b61029d60048036038101906102989190611d15565b61089b565b005b6102b960048036038101906102b49190611e8a565b6108b1565b005b6102d560048036038101906102d09190611b74565b610913565b6040516102e29190611b26565b60405180910390f35b61030560048036038101906103009190611f0d565b6109ac565b6040516103129190611a7b565b60405180910390f35b60006103276006610a40565b905090565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806103f757507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b80610407575061040682610a4e565b5b9050919050565b60606000805461041d90611f7c565b80601f016020809104026020016040519081016040528092919081815260200182805461044990611f7c565b80156104965780601f1061046b57610100808354040283529160200191610496565b820191906000526020600020905b81548152906001019060200180831161047957829003601f168201915b5050505050905090565b60006104ab82610ab8565b6004600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b60006104f1826106cc565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603610561576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105589061201f565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610580610b03565b73ffffffffffffffffffffffffffffffffffffffff1614806105af57506105ae816105a9610b03565b6109ac565b5b6105ee576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105e5906120b1565b60405180910390fd5b6105f88383610b0b565b505050565b61060e610608610b03565b82610bc4565b61064d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161064490612143565b60405180910390fd5b610658838383610c59565b505050565b6000600190505b8181116106a8576106756006610f52565b60006106816006610a40565b905061069461068e610b03565b82610f68565b5080806106a090612192565b915050610664565b5050565b6106c7838383604051806020016040528060008152506108b1565b505050565b6000806106d883610f86565b9050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1603610749576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074090612226565b60405180910390fd5b80915050919050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036107c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b9906122b8565b60405180910390fd5b600360008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60606001805461081890611f7c565b80601f016020809104026020016040519081016040528092919081815260200182805461084490611f7c565b80156108915780601f1061086657610100808354040283529160200191610891565b820191906000526020600020905b81548152906001019060200180831161087457829003601f168201915b5050505050905090565b6108ad6108a6610b03565b8383610fc3565b5050565b6108c26108bc610b03565b83610bc4565b610901576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108f890612143565b60405180910390fd5b61090d8484848461112f565b50505050565b6060600060405180610160016040528061013c8152602001612a7561013c9139905060006109408461118b565b61094983611259565b6109528661118b565b604051602001610964939291906124b6565b6040516020818303038152906040529050600061098082611259565b604051602001610990919061255f565b6040516020818303038152906040529050809350505050919050565b6000600560008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b600081600001549050919050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b610ac1816113d1565b610b00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610af790612226565b60405180910390fd5b50565b600033905090565b816004600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16610b7e836106cc565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b600080610bd0836106cc565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480610c125750610c1181856109ac565b5b80610c5057508373ffffffffffffffffffffffffffffffffffffffff16610c38846104a0565b73ffffffffffffffffffffffffffffffffffffffff16145b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16610c79826106cc565b73ffffffffffffffffffffffffffffffffffffffff1614610ccf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cc6906125f3565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610d3e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d3590612685565b60405180910390fd5b610d4b8383836001611412565b8273ffffffffffffffffffffffffffffffffffffffff16610d6b826106cc565b73ffffffffffffffffffffffffffffffffffffffff1614610dc1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610db8906125f3565b60405180910390fd5b6004600082815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff02191690556001600360008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825403925050819055506001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4610f4d8383836001611418565b505050565b6001816000016000828254019250508190555050565b610f8282826040518060200160405280600081525061141e565b5050565b60006002600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff1603611031576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611028906126f1565b60405180910390fd5b80600560008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516111229190611a7b565b60405180910390a3505050565b61113a848484610c59565b61114684848484611479565b611185576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161117c90612783565b60405180910390fd5b50505050565b60606000600161119a84611600565b01905060008167ffffffffffffffff8111156111b9576111b8611d5f565b5b6040519080825280601f01601f1916602001820160405280156111eb5781602001600182028036833780820191505090505b509050600082602001820190505b60011561124e578080600190039150507f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a8581611242576112416127a3565b5b049450600085036111f9575b819350505050919050565b6060600082510361127b576040518060200160405280600081525090506113cc565b6000604051806060016040528060408152602001612a3560409139905060006003600285516112aa91906127d2565b6112b49190612806565b60046112c09190612837565b905060006020826112d191906127d2565b67ffffffffffffffff8111156112ea576112e9611d5f565b5b6040519080825280601f01601f19166020018201604052801561131c5781602001600182028036833780820191505090505b509050818152600183018586518101602084015b8183101561138b576003830192508251603f8160121c168501518253600182019150603f81600c1c168501518253600182019150603f8160061c168501518253600182019150603f8116850151825360018201915050611330565b6003895106600181146113a557600281146113b5576113c0565b613d3d60f01b60028303526113c0565b603d60f81b60018303525b50505050508093505050505b919050565b60008073ffffffffffffffffffffffffffffffffffffffff166113f383610f86565b73ffffffffffffffffffffffffffffffffffffffff1614159050919050565b50505050565b50505050565b6114288383611753565b6114356000848484611479565b611474576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161146b90612783565b60405180910390fd5b505050565b600061149a8473ffffffffffffffffffffffffffffffffffffffff16611970565b156115f3578373ffffffffffffffffffffffffffffffffffffffff1663150b7a026114c3610b03565b8786866040518563ffffffff1660e01b81526004016114e594939291906128ce565b6020604051808303816000875af192505050801561152157506040513d601f19601f8201168201806040525081019061151e919061292f565b60015b6115a3573d8060008114611551576040519150601f19603f3d011682016040523d82523d6000602084013e611556565b606091505b50600081510361159b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161159290612783565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149150506115f8565b600190505b949350505050565b600080600090507a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000831061165e577a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008381611654576116536127a3565b5b0492506040810190505b6d04ee2d6d415b85acef8100000000831061169b576d04ee2d6d415b85acef81000000008381611691576116906127a3565b5b0492506020810190505b662386f26fc1000083106116ca57662386f26fc1000083816116c0576116bf6127a3565b5b0492506010810190505b6305f5e10083106116f3576305f5e10083816116e9576116e86127a3565b5b0492506008810190505b612710831061171857612710838161170e5761170d6127a3565b5b0492506004810190505b6064831061173b5760648381611731576117306127a3565b5b0492506002810190505b600a831061174a576001810190505b80915050919050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036117c2576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117b9906129a8565b60405180910390fd5b6117cb816113d1565b1561180b576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161180290612a14565b60405180910390fd5b611819600083836001611412565b611822816113d1565b15611862576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161185990612a14565b60405180910390fd5b6001600360008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282540192505081905550816002600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a461196c600083836001611418565b5050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b6000819050919050565b6119a681611993565b82525050565b60006020820190506119c1600083018461199d565b92915050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b611a10816119db565b8114611a1b57600080fd5b50565b600081359050611a2d81611a07565b92915050565b600060208284031215611a4957611a486119d1565b5b6000611a5784828501611a1e565b91505092915050565b60008115159050919050565b611a7581611a60565b82525050565b6000602082019050611a906000830184611a6c565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611ad0578082015181840152602081019050611ab5565b60008484015250505050565b6000601f19601f8301169050919050565b6000611af882611a96565b611b028185611aa1565b9350611b12818560208601611ab2565b611b1b81611adc565b840191505092915050565b60006020820190508181036000830152611b408184611aed565b905092915050565b611b5181611993565b8114611b5c57600080fd5b50565b600081359050611b6e81611b48565b92915050565b600060208284031215611b8a57611b896119d1565b5b6000611b9884828501611b5f565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611bcc82611ba1565b9050919050565b611bdc81611bc1565b82525050565b6000602082019050611bf76000830184611bd3565b92915050565b611c0681611bc1565b8114611c1157600080fd5b50565b600081359050611c2381611bfd565b92915050565b60008060408385031215611c4057611c3f6119d1565b5b6000611c4e85828601611c14565b9250506020611c5f85828601611b5f565b9150509250929050565b600080600060608486031215611c8257611c816119d1565b5b6000611c9086828701611c14565b9350506020611ca186828701611c14565b9250506040611cb286828701611b5f565b9150509250925092565b600060208284031215611cd257611cd16119d1565b5b6000611ce084828501611c14565b91505092915050565b611cf281611a60565b8114611cfd57600080fd5b50565b600081359050611d0f81611ce9565b92915050565b60008060408385031215611d2c57611d2b6119d1565b5b6000611d3a85828601611c14565b9250506020611d4b85828601611d00565b9150509250929050565b600080fd5b600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b611d9782611adc565b810181811067ffffffffffffffff82111715611db657611db5611d5f565b5b80604052505050565b6000611dc96119c7565b9050611dd58282611d8e565b919050565b600067ffffffffffffffff821115611df557611df4611d5f565b5b611dfe82611adc565b9050602081019050919050565b82818337600083830152505050565b6000611e2d611e2884611dda565b611dbf565b905082815260208101848484011115611e4957611e48611d5a565b5b611e54848285611e0b565b509392505050565b600082601f830112611e7157611e70611d55565b5b8135611e81848260208601611e1a565b91505092915050565b60008060008060808587031215611ea457611ea36119d1565b5b6000611eb287828801611c14565b9450506020611ec387828801611c14565b9350506040611ed487828801611b5f565b925050606085013567ffffffffffffffff811115611ef557611ef46119d6565b5b611f0187828801611e5c565b91505092959194509250565b60008060408385031215611f2457611f236119d1565b5b6000611f3285828601611c14565b9250506020611f4385828601611c14565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680611f9457607f821691505b602082108103611fa757611fa6611f4d565b5b50919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b6000612009602183611aa1565b915061201482611fad565b604082019050919050565b6000602082019050818103600083015261203881611ffc565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60008201527f6b656e206f776e6572206f7220617070726f76656420666f7220616c6c000000602082015250565b600061209b603d83611aa1565b91506120a68261203f565b604082019050919050565b600060208201905081810360008301526120ca8161208e565b9050919050565b7f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560008201527f72206f7220617070726f76656400000000000000000000000000000000000000602082015250565b600061212d602d83611aa1565b9150612138826120d1565b604082019050919050565b6000602082019050818103600083015261215c81612120565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061219d82611993565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82036121cf576121ce612163565b5b600182019050919050565b7f4552433732313a20696e76616c696420746f6b656e2049440000000000000000600082015250565b6000612210601883611aa1565b915061221b826121da565b602082019050919050565b6000602082019050818103600083015261223f81612203565b9050919050565b7f4552433732313a2061646472657373207a65726f206973206e6f74206120766160008201527f6c6964206f776e65720000000000000000000000000000000000000000000000602082015250565b60006122a2602983611aa1565b91506122ad82612246565b604082019050919050565b600060208201905081810360008301526122d181612295565b9050919050565b600081905092915050565b7f7b226e616d65223a2022546573742044617070204e4654732023000000000000600082015250565b6000612319601a836122d8565b9150612324826122e3565b601a82019050919050565b600061233a82611a96565b61234481856122d8565b9350612354818560208601611ab2565b80840191505092915050565b7f222c20226465736372697074696f6e223a2022546573742044617070204e465460008201527f7320666f722074657374696e672e222c2022696d616765223a2022646174613a60208201527f696d6167652f7376672b786d6c3b6261736536342c0000000000000000000000604082015250565b60006123e26055836122d8565b91506123ed82612360565b605582019050919050565b7f222c202261747472696275746573223a205b7b2274726169745f74797065223a60008201527f2022546f6b656e204964222c202276616c7565223a2022000000000000000000602082015250565b60006124546037836122d8565b915061245f826123f8565b603782019050919050565b7f227d5d7d00000000000000000000000000000000000000000000000000000000600082015250565b60006124a06004836122d8565b91506124ab8261246a565b600482019050919050565b60006124c18261230c565b91506124cd828661232f565b91506124d8826123d5565b91506124e4828561232f565b91506124ef82612447565b91506124fb828461232f565b915061250682612493565b9150819050949350505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c000000600082015250565b6000612549601d836122d8565b915061255482612513565b601d82019050919050565b600061256a8261253c565b9150612576828461232f565b915081905092915050565b7f4552433732313a207472616e736665722066726f6d20696e636f72726563742060008201527f6f776e6572000000000000000000000000000000000000000000000000000000602082015250565b60006125dd602583611aa1565b91506125e882612581565b604082019050919050565b6000602082019050818103600083015261260c816125d0565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b600061266f602483611aa1565b915061267a82612613565b604082019050919050565b6000602082019050818103600083015261269e81612662565b9050919050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b60006126db601983611aa1565b91506126e6826126a5565b602082019050919050565b6000602082019050818103600083015261270a816126ce565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b600061276d603283611aa1565b915061277882612711565b604082019050919050565b6000602082019050818103600083015261279c81612760565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006127dd82611993565b91506127e883611993565b9250828201905080821115612800576127ff612163565b5b92915050565b600061281182611993565b915061281c83611993565b92508261282c5761282b6127a3565b5b828204905092915050565b600061284282611993565b915061284d83611993565b925082820261285b81611993565b9150828204841483151761287257612871612163565b5b5092915050565b600081519050919050565b600082825260208201905092915050565b60006128a082612879565b6128aa8185612884565b93506128ba818560208601611ab2565b6128c381611adc565b840191505092915050565b60006080820190506128e36000830187611bd3565b6128f06020830186611bd3565b6128fd604083018561199d565b818103606083015261290f8184612895565b905095945050505050565b60008151905061292981611a07565b92915050565b600060208284031215612945576129446119d1565b5b60006129538482850161291a565b91505092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000612992602083611aa1565b915061299d8261295c565b602082019050919050565b600060208201905081810360008301526129c181612985565b9050919050565b7f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000600082015250565b60006129fe601c83611aa1565b9150612a09826129c8565b602082019050919050565b60006020820190508181036000830152612a2d816129f1565b905091905056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f3c737667206865696768743d22333530222077696474683d22333530222076696577426f783d2230203020313030203130302220786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323030302f737667223e3c646566733e3c706174682069643d224d7950617468222066696c6c3d226e6f6e6522207374726f6b653d227265642220643d224d31302c3930205139302c39302039302c3435205139302c31302035302c3130205131302c31302031302c3430205131302c37302034352c3730205137302c37302037352c353022202f3e3c2f646566733e3c746578743e3c746578745061746820687265663d22234d7950617468223e517569636b2062726f776e20666f78206a756d7073206f76657220746865206c617a7920646f672e3c2f74657874506174683e3c2f746578743e3c2f7376673ea2646970667358221220922487cf7bfec55ad9cf0c646397333bb79204b1a8ef63134f78b23d697570ef64736f6c63430008120033",
"gas": "0x26e8af",
"gasPrice": "0x18e17",
"value": "0x0"
}
]
}`
// balanceParamsStr, _ := json.Marshal(balanceParams)
eth_getBalanceStr = escapeAllStr(eth_getBalanceStr, "selfAddress", user.Address)
personal_signStr = escapeAllStr(personal_signStr, "selfAddress", user.Address)
eth_signTypedData_v4Str = escapeAllStr(eth_signTypedData_v4Str, "selfAddress", user.Address)
eth_sendTransactionStrNative = escapeAllStr(eth_sendTransactionStrNative, "selfAddress", user.Address)
eth_sendTransactionStrNative = escapeAllStr(eth_sendTransactionStrNative, "botAddress", botAddress)
eth_sendTransactionStrToken = escapeAllStr(eth_sendTransactionStrToken, "selfAddress", user.Address)
eth_sendTransactionStrToken = escapeAllStr(eth_sendTransactionStrToken, "botAddress", botAddress[2:])
sendTransactionStrSwap = escapeAllStr(sendTransactionStrSwap, "selfAddress", user.Address)
eth_sendTransactionApproveStr = escapeAllStr(eth_sendTransactionApproveStr, "selfAddress", user.Address)
eth_sendTransactionApproveStr = escapeAllStr(eth_sendTransactionApproveStr, "botAddress", botAddress[2:])
sendTransactionStrTransferFrom = escapeAllStr(sendTransactionStrTransferFrom, "selfAddress", user.Address)
sendTransactionStrMint = escapeAllStr(sendTransactionStrMint, "selfAddress", user.Address)
sendTransactionStrDeploy = escapeAllStr(sendTransactionStrDeploy, "selfAddress", user.Address)
homeMenuMarkup.InlineKeyboard[0][0].CallbackData = ð_getBalanceStr
homeMenuMarkup.InlineKeyboard[1][0].CallbackData = &personal_signStr
homeMenuMarkup.InlineKeyboard[2][0].CallbackData = ð_signTypedData_v4Str
homeMenuMarkup.InlineKeyboard[3][0].CallbackData = ð_sendTransactionStrNative
//合约币转账
homeMenuMarkup.InlineKeyboard[4][0].CallbackData = ð_sendTransactionStrToken
homeMenuMarkup.InlineKeyboard[5][0].CallbackData = &sendTransactionStrSwap
homeMenuMarkup.InlineKeyboard[6][0].CallbackData = ð_sendTransactionApproveStr
homeMenuMarkup.InlineKeyboard[7][0].CallbackData = &sendTransactionStrTransferFrom
homeMenuMarkup.InlineKeyboard[8][0].CallbackData = &sendTransactionStrMint
homeMenuMarkup.InlineKeyboard[9][0].CallbackData = &sendTransactionStrDeploy
_, err = bot.Send(msg)
}
}
if err != nil {
log.Printf("An error occured: %s", err.Error())
}
}
func escapeAllStr(text, old, new string) string {
text = strings.ReplaceAll(text, "\n", "")
text = strings.ReplaceAll(text, "\t", "")
text = strings.ReplaceAll(text, " ", "")
text = strings.ReplaceAll(text, old, new)
return text
}
func handleButton(query *boxbotapi.CallbackQuery) {
message := query.Message
var text = query.Data
markup := boxbotapi.NewInlineKeyboardMarkup()
markup = homeMenuMarkup
// Replace menu text and keyboard
msg := boxbotapi.NewEditMessageTextAndMarkup(message.Chat.ID, message.Chat.Type, message.MessageID, text, markup)
msg.ParseMode = boxbotapi.ModeHTML
bot.Send(msg)
}