🥜
DangerAcorn Docs
  • DangerAcorn
    • Welcome
  • ACORN API
    • Get Started
      • Request an API Key
      • View API Plans
  • API STATUS
    • Tron - 🟡
    • Solana - 🚧
    • Ethereum - 🚧
  • Tron Network
    • Dedicated Nodes
    • SunPump API
      • Trade API
        • Local Trade API
      • Get Data
        • Get Quote
        • Get Token Details
        • Get Token Holders
        • Get Recent Trades
        • Get Token Balance
        • 🚧Webhooks
          • Subscriptions
    • Helpers
      • Create Wallet
      • Transfer
      • Approve Tokens
      • Check Allowance
      • 🚧Webhooks
        • Subscriptions
  • Solana Network
    • PumpFun API
      • Trade API
        • Live Trade API
        • Local Trade API
      • Get Data
        • Get Token Details
        • Get Token Holders
        • Get Recent Trades
        • 🚧Get Curve Progress
        • Get Token Price
        • 🚧Webhooks
          • Subscriptions
    • Helpers
      • Create Wallet
      • Transfer
      • Webhooks
        • Subscriptions
  • Socials
    • Discord
    • Telegram
Powered by GitBook
On this page
  • Endpoint
  • Parameters
  • Example Approve Requests
  • Example Response JSON
  • Error Responses
  • Notes

Was this helpful?

  1. Tron Network
  2. Helpers

Approve Tokens

This endpoint returns an unsigned transaction to approve an unlimited amount of tokens for trading on SunPump. This should be signed and broadcasted locally or on the client side.

Endpoint

  • URL: /sunpump/approve

  • Method: POST

  • Content-Type: application/json

  • API Key Header: api-key: your-api-key

Parameters

Parameter
Type
Required
Description

tokenAddress

string

Yes

Token Contract Address

userAddress

string

Yes

Public Tron Address of sender

Example Approve Requests

curl -X POST https://api.dangeracorn.com/sunpump/approve \
-H "Content-Type: application/json" \
-H "api-key: your-api-key" \
-d '{
  "tokenAddress": "token-contract-address",
  "userAddress": "sender-public-tron-address"
}'
npm install axios
const axios = require('axios');

const sellRequest = async () => {
  const response = await axios.post('https://api.dangeracorn.com/sunpump/approve', {
    tokenAddress: 'token-contract-address',
    userAddress: 'sender-public-tron-address'
  }, {
    headers: {
      'Content-Type': 'application/json',
      'api-key': 'your-api-key'
    }
  });

  const { unsignedTx } = await response.data;
};

sellRequest();
pip install requests
import requests

url = 'https://api.dangeracorn.com/sunpump/approve'
headers = {
    'Content-Type': 'application/json',
    'api-key': 'your-api-key'
}

data = {
    tokenAddress: 'token-contract-address',
    userAddress: 'sender-public-tron-address'
}

response = requests.post(url, json=data, headers=headers)
print(response.json())
package main

import (
	"bytes"
	"encoding/json"
	"net/http"
	"fmt"
)

func main() {
	data := map[string]interface{}{
	    tokenAddress: 'token-contract-address',
	    userAddress: 'sender-public-tron-address'
	}

	payload, _ := json.Marshal(data)
	req, _ := http.NewRequest("POST", "https://api.dangeracorn.com/sunpump/approve", bytes.NewBuffer(payload))
	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("api-key", "your-api-key")

	client := &http.Client{}
	resp, _ := client.Do(req)
	defer resp.Body.Close()

	fmt.Println("Response Status:", resp.Status)
}
<?php

$url = 'https://api.dangeracorn.com/sunpump/approve';

$data = array(
    'tokenAddress' => 'token-contract-address',
    'userAddress' => 'sender-public-tron-address'
);

$options = array(
    'http' => array(
        'header'  => "Content-Type: application/json\r\n" .
                     "api-key: your-api-key\r\n",
        'method'  => 'POST',
        'content' => json_encode($data),
    ),
);

$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);

echo $response;

Example Response JSON

{
  "unsignedTx": {
    "raw_data": { /* transaction data */ },
    "txID": "b69f27c7bfcf54a464294f1df99aaeff1b53714a12a80460709b20923a24486c" // example
  },
  "status": "unsigned",
  "code": "200"
}

Error Responses

Invalid Parameters

{
  "error": "Invalid parameters",
  "message": "You must only provide tokenAddress and userAddress",
  "code": "400"
}

Insufficient Funds

{
  "error": "Insufficient funds",
  "message": "Your account does not have enough funds to perform this transaction.",
  "code": "400"
}

Notes

  • Rate Limiting: This endpoint is rate-limited according to your plan's API key limits. Ensure that you handle these limits in your application.

  • Unsigned Transactions: The API returns unsigned transactions that users must sign before broadcasting.

PreviousTransferNextCheck Allowance

Last updated 9 months ago

Was this helpful?