Ethereum & EVM

This guide covers Ethereum and EVM-compatible blockchain transactions using the BitPowr API. EVM transactions support native ETH transfers, ERC20 token transfers, custom gas management, and advanced operations like approve/transferFrom workflows for delegated spending.

API Endpoints

1. Estimate Transaction Fee

POST /transactions/estimate - Get estimated gas fees before sending

2. Create EVM Transaction

POST /transactions - Create and send Ethereum/EVM transactions


Estimate Transaction Fees

Before creating EVM transactions, estimate gas fees to optimize transaction costs and ensure sufficient funds.

Endpoint

POST /transactions/estimate

Request Headers

Content-Type: application/json
Authorization: Bearer <encodedToken>

Parameters

ParameterTypeRequiredDescription
chainstringYesEVM chain (ETHEREUM, POLYGON, BSC, etc.)
walletIdstringYesUnique identifier for the wallet
tokenstringYesToken type (ETH, USDC, USDT, etc.)
tosarrayYesArray of destination objects
fromarrayNoArray of sender addresses
operationstringNoOperation type (transfer, approve, transferFrom)

Example Request

curl --request POST \
     --url https://developers.bitpowr.com/api/v1/transactions/estimate \
     -H 'content-type: application/json' \
     -H 'authorization: Bearer <encodedToken>' \
     -d '{
          "chain": "ETHEREUM",
          "walletId": "e3455-15b5-46ad-84de-34555",
          "token": "USDC",
          "tos": [{
              "address": "0x1180a4c0c71b5eb0256edcffcc3389f1f085c502",
              "value": "100"
          }],
          "from": ["0x40fa00fe4a0a655240fede3149e9ea55118241e2"]
      }'

Response Format

{
  "fee": {
    "fast": {
      "gasFee": "0.000119673736860231",
      "gasLimit": 46467,
      "gasPrice": "2575456493"
    },
    "slow": {
      "gasFee": "0.0000697005",
      "gasLimit": 46467,
      "gasPrice": "1500000000"
    },
    "medium": {
      "gasFee": "0.000049973236860231",
      "gasLimit": 46467,
      "gasPrice": "1075456493"
    }
  }
}

EVM Transaction Parameters

Core Parameters

ParameterTypeRequiredDescription
walletIdstringYesUnique identifier for the wallet
assetTypestringYesAsset type (ETH, USDC, USDC_BASE, etc.)
tosarrayYesArray of destination objects
fromarrayNoArray of sender addresses
descriptionstringNoTransaction description

Gas Management Parameters

ParameterTypeDescription
gasLimitstringMaximum gas units to use for the transaction
gasPricestringGas price in wei (for legacy transactions)
feestringTransaction fee in ETH (alternative to gasPrice)

Advanced Parameters

ParameterTypeDescription
operationstringOperation type (transfer, approve, transferFrom)
spenderAddressstringAddress to approve for spending (approve operations)
feeAddressstringAddress to pay transaction fees (transferFrom operations)

Output Object Structure

ParameterTypeRequiredDescription
addressstringYesRecipient Ethereum address (0x...)
valuestringYesAmount to send (in token units)

EVM Transaction Types

1. Send Ethereum (ETH) Transaction

Send native ETH on Ethereum or native tokens on other EVM chains.

Basic ETH Transfer

curl --request POST \
     --url https://developers.bitpowr.com/api/v1/transactions \
     -H 'content-type: application/json' \
     -H 'authorization: Bearer <encodedToken>' \
     -d '{
          "walletId": "e3455-15b5-46ad-84de-34555",
          "assetType": "ETH",
          "from": ["0x40fa00fe4a0a655240fede3149e9ea55118241e2"],
          "tos": [{
              "address": "0x1180a4c0c71b5eb0256edcffcc3389f1f085c502",
              "value": "0.01"
          }],
          "description": "ETH transfer"
      }'

ETH Transfer with Custom Gas

curl --request POST \
     --url https://developers.bitpowr.com/api/v1/transactions \
     -H 'content-type: application/json' \
     -H 'authorization: Bearer <encodedToken>' \
     -d '{
          "walletId": "e3455-15b5-46ad-84de-34555",
          "assetType": "ETH",
          "from": ["0x40fa00fe4a0a655240fede3149e9ea55118241e2"],
          "tos": [{
              "address": "0x1180a4c0c71b5eb0256edcffcc3389f1f085c502",
              "value": "0.01"
          }],
          "fee": 0.0001,
          "gasLimit": "21000",
          "gasPrice": "2000000000",
          "description": "ETH transfer with custom gas"
      }'

2. Send ERC20 Token Transaction

Send ERC20 tokens like USDC, USDT, or other standard tokens on Ethereum and EVM-compatible chains.

USDC on Ethereum

curl --request POST \
     --url https://developers.bitpowr.com/api/v1/transactions \
     -H 'content-type: application/json' \
     -H 'authorization: Bearer <encodedToken>' \
     -d '{
          "walletId": "e3455-15b5-46ad-84de-34555",
          "assetType": "USDC",
          "from": ["0x40fa00fe4a0a655240fede3149e9ea55118241e2"],
          "tos": [{
              "address": "0x1180a4c0c71b5eb0256edcffcc3389f1f085c502",
              "value": "100"
          }],
          "description": "USDC transfer on Ethereum"
      }'

USDC on Base

curl --request POST \
     --url https://developers.bitpowr.com/api/v1/transactions \
     -H 'content-type: application/json' \
     -H 'authorization: Bearer <encodedToken>' \
     -d '{
          "walletId": "e3455-15b5-46ad-84de-34555",
          "assetType": "USDC_BASE",
          "from": ["0x40fa00fe4a0a655240fede3149e9ea55118241e2"],
          "tos": [{
              "address": "0x1180a4c0c71b5eb0256edcffcc3389f1f085c502",
              "value": "100"
          }],
          "description": "USDC transfer on Base"
      }'

ERC20 Transfer with Custom Gas

curl --request POST \
     --url https://developers.bitpowr.com/api/v1/transactions \
     -H 'content-type: application/json' \
     -H 'authorization: Bearer <encodedToken>' \
     -d '{
          "walletId": "e3455-15b5-46ad-84de-34555",
          "assetType": "USDC",
          "from": ["0x40fa00fe4a0a655240fede3149e9ea55118241e2"],
          "tos": [{
              "address": "0x1180a4c0c71b5eb0256edcffcc3389f1f085c502",
              "value": "100"
          }],
          "fee": 0.01,
          "gasLimit": "65000",
          "gasPrice": "2000000000",
          "description": "USDC transfer with custom gas"
      }'

3. Send Transaction with Custom Gas Parameters

Control transaction fees precisely by specifying gas limit, gas price, and fee parameters.

All Gas Parameters Required

curl --request POST \
     --url https://developers.bitpowr.com/api/v1/transactions \
     -H 'content-type: application/json' \
     -H 'authorization: Bearer <encodedToken>' \
     -d '{
          "walletId": "e3455-15b5-46ad-84de-34555",
          "assetType": "USDC",
          "from": ["0x40fa00fe4a0a655240fede3149e9ea55118241e2"],
          "tos": [{
              "address": "0x1180a4c0c71b5eb0256edcffcc3389f1f085c502",
              "value": "50"
          }],
          "gasLimit": "65000",
          "gasPrice": "3000000000",
          "fee": "0.000195",
          "description": "Transaction with all custom gas parameters"
      }'

Gas Parameter Guidelines:

  • gasLimit: 21000 for ETH transfers, 65000+ for ERC20 transfers
  • gasPrice: In wei (1 gwei = 1,000,000,000 wei)
  • fee: Total transaction fee in ETH (gasLimit × gasPrice ÷ 10^18)

Fee Calculation:

fee = (gasLimit × gasPrice) ÷ 1,000,000,000,000,000,000
Example: (65000 × 3000000000) ÷ 10^18 = 0.000195 ETH

4. Approve and TransferFrom Workflow

The approve/transferFrom pattern allows one address to spend tokens on behalf of another. This is commonly used for DeFi applications, payment processors, and automated trading systems.

Step 1: Send Approve Transaction

First, approve a spender address to spend a specific amount of tokens on your behalf.

curl --request POST \
     --url https://developers.bitpowr.com/api/v1/transactions \
     -H 'content-type: application/json' \
     -H 'authorization: Bearer <encodedToken>' \
     -d '{
          "walletId": "0722efe5-1d0a-41ae-9d7f-b22374062f81",
          "assetType": "USDC",
          "from": ["0x40fa00fe4a0a655240fede3149e9ea55118241e2"],
          "tos": [{
              "address": "0xA0b86a33E6A8b5E1e8eb7e0D8E5C9b8a52C9c3A8",
              "value": "1000"
          }],
          "spenderAddress": "0x1180a4c0c71b5eb0256edcffcc3389f1f085c502",
          "operation": "approve",
          "gasLimit": "50000",
          "gasPrice": "2000000000",
          "fee": "0.0001",
          "description": "Approve 1000 USDC for spender"
      }'

Approve Transaction Parameters:

  • tos[0].address: The spenderAddress in this case
  • tos[0].value: Total allowance amount (not per-transaction limit)
  • spenderAddress: Address that will be allowed to spend your tokens
  • operation: Must be "approve"

Step 2: Wait for Confirmation

Monitor the approve transaction until it's confirmed on the blockchain. You can check the transaction status using the returned transaction hash.

Step 3: Send TransferFrom Transaction

After the approve transaction is confirmed, the spender address can execute transferFrom operations.

curl --request POST \
     --url https://developers.bitpowr.com/api/v1/transactions \
     -H 'content-type: application/json' \
     -H 'authorization: Bearer <encodedToken>' \
     -d '{
          "walletId": "0722efe5-1d0a-41ae-9d7f-b22374062f81",
          "assetType": "USDC",
          "from": ["0x40fa00fe4a0a655240fede3149e9ea55118241e2"],
          "tos": [{
              "address": "0x742d35Cc6644C0532925a3b8C17DAb6F2c8f1234",
              "value": "250"
          }],
          "feeAddress": "0x1180a4c0c71b5eb0256edcffcc3389f1f085c502",
          "operation": "transferFrom",
          "gasLimit": "70000",
          "gasPrice": "2000000000",
          "fee": "0.00014",
          "description": "Transfer 250 USDC from approved allowance"
      }'

TransferFrom Transaction Parameters:

  • from[0]: Original token owner's address (must have approved the feeAddress)
  • tos[0].address: Final recipient of the tokens
  • tos[0].value: Amount to transfer (must not exceed approved allowance)
  • feeAddress: Address that pays gas fees (must be the approved spender)
  • operation: Must be "transferFrom"

Approve/TransferFrom Process Flow

1. Token Owner (0x40fa...) approves Spender (0x1180...)
   ↓
2. Approve transaction confirms on blockchain
   ↓
3. Spender (0x1180...) can now execute transferFrom
   ↓
4. TransferFrom moves tokens from Owner to Recipient
   ↓
5. Spender pays gas fees, Owner's tokens are transferred

Use Cases for Approve/TransferFrom

  1. Payment Processors: Allow a service to spend tokens on behalf of users
  2. DeFi Protocols: Enable smart contracts to move user tokens
  3. Automated Trading: Let trading bots execute transactions with user funds
  4. Subscription Services: Allow recurring payments from user wallets
  5. Corporate Wallets: Enable employees to spend from company accounts

Important Notes

  • Allowance Management: The approved amount is the total allowance, not per-transaction
  • Security: Only approve trusted addresses with the minimum necessary allowance
  • Gas Costs: Both approve and transferFrom operations require gas fees
  • Allowance Tracking: Monitor remaining allowance after each transferFrom
  • Revoke Approval: Set allowance to "0" to revoke spending permissions

Transaction Response Format

All EVM transaction requests return a standardized response.

{
  "status": "success",
  "data": {
    "hash": "0x8f2a5b3c9d1e4f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0c1d2e3f4a5b6c7d8e9f0a",
    "status": "PENDING",
    "amount": "100",
    "uid": "6680c116-c803-4e46-aa99-2f261cd216ac",
    "assetType": "USDC",
    "chain": "ETHEREUM",
    "fee": "0.000195",
    "gasLimit": "65000",
    "gasPrice": "3000000000",
    "ref": "BTP-EthTx123#ABC456",
    "network": "MAINNET"
  }
}

Response Fields

FieldTypeDescription
hashstringEthereum transaction hash (0x...)
statusstringTransaction status (PENDING, CONFIRMED, FAILED)
amountstringAmount sent in token units
uidstringUnique BitPowr transaction identifier
assetTypestringToken type (ETH, USDC_ETH, etc.)
chainstringBlockchain name (ETHEREUM, POLYGON, BSC)
feestringTransaction fee paid in ETH
gasLimitstringGas limit used
gasPricestringGas price in wei
refstringBitPowr reference number
networkstringNetwork type (MAINNET or TESTNET)

EVM Workflow Examples

1. Basic Token Transfer Workflow

1. Estimate fees → POST /estimate-transaction
2. Create transaction → POST /transactions
3. Monitor confirmation using transaction hash

2. Custom Gas Management Workflow

1. Check current network gas prices
2. Calculate optimal gasLimit and gasPrice
3. Create transaction with custom gas parameters
4. Monitor transaction speed and adjust for future transactions

3. Approve/TransferFrom Workflow

1. Send approve transaction with total allowance
2. Wait for approve transaction confirmation
3. Send transferFrom transaction(s) as needed
4. Monitor remaining allowance
5. Revoke or adjust allowance when done

Best Practices

Gas Management

  1. Estimate First: Always estimate gas fees before transactions
  2. Buffer Gas Limit: Add 10-20% buffer to estimated gas limit
  3. Monitor Network: Check network congestion for optimal gas prices
  4. Priority Fees: Use higher gas prices for urgent transactions

Security

  1. Address Validation: Verify all addresses before sending transactions
  2. Amount Verification: Double-check token amounts and decimals
  3. Allowance Limits: Only approve the minimum necessary allowance
  4. Regular Monitoring: Track transaction status and confirmations

Error Handling

  1. Insufficient Funds: Check ETH balance for gas fees
  2. Gas Estimation Failures: Increase gas limit or check contract interactions
  3. Nonce Issues: Handle nonce management for multiple transactions
  4. Network Congestion: Implement retry logic with adjusted gas prices

Address Format & Requirements

Ethereum Addresses

  • Format: Hexadecimal strings starting with 0x
  • Length: 42 characters (including 0x prefix)
  • Case: Case-insensitive, but checksummed addresses preferred
  • Example: 0x742d35Cc6644C0532925a3b8C17DAb6F2c8f1234

Gas Units Guidelines

  • ETH Transfer: 21,000 gas
  • ERC20 Transfer: 65,000 - 100,000 gas
  • ERC20 Approve: 45,000 - 60,000 gas
  • TransferFrom: 70,000 - 100,000 gas

Common Gas Prices (in Gwei)

  • Slow: 10-20 Gwei (10,000,000,000 - 20,000,000,000 wei)
  • Standard: 20-30 Gwei (20,000,000,000 - 30,000,000,000 wei)
  • Fast: 30-50 Gwei (30,000,000,000 - 50,000,000,000 wei)
  • Urgent: 50+ Gwei (50,000,000,000+ wei)