Skip to main content

wallet/getcontract

Comprehensive Contract Analysis

Dwellir's TRON endpoints provide complete smart contract information including bytecode and metadata. Build contract explorers and verification tools with our optimized contract data API.

Explore smart contracts →

Retrieves comprehensive information about a deployed smart contract on the TRON network, including bytecode, ABI, creator details, and deployment information.

When to Use This Method#

wallet/getcontract is essential for:

  • Contract Verification - Verify deployed contract matches source code
  • ABI Retrieval - Get contract interface for interaction
  • Contract Analysis - Analyze contract functionality and security
  • Block Explorers - Display contract information to users
  • Development Tools - Build contract interaction interfaces

Parameters#

  1. value - string (required)

    • Smart contract address in Base58 format
    • Example: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t" (USDT contract)
  2. visible - boolean (optional, default: false)

    • true - Use Base58 address format in response
    • false - Use hex address format in response
{
"value": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"visible": true
}

Returns#

Contract Object containing:

  • bytecode - Contract bytecode (hex string)
  • name - Contract name (if available)
  • abi - Contract ABI (if available)
  • origin_address - Contract creator address
  • origin_energy_limit - Energy limit set by creator
  • contract_address - Contract address
  • code_hash - Hash of the contract code

Implementation Examples#

# Get contract information
curl -X POST "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getcontract" \
-H "Content-Type: application/json" \
-d '{
"value": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"visible": true
}'

# Extract key contract information
curl -s -X POST "https://api-tron-mainnet.n.dwellir.com/YOUR_API_KEY/wallet/getcontract" \
-H "Content-Type: application/json" \
-d '{
"value": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"visible": true
}' | jq '{
address: "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
has_contract: (.bytecode != null and .bytecode != ""),
creator: .origin_address,
energy_limit: .origin_energy_limit,
name: .name // "Unknown",
has_abi: (.abi != null and .abi != ""),
bytecode_size: (.bytecode | length) / 2,
code_hash: .code_hash
}'

Response Examples#

Verified Contract (USDT)#

{
"bytecode": "608060405234801561001057600080fd5b50600436106101735760003560e01c80636a...",
"name": "TetherToken",
"abi": "[{\"inputs\":[{\"name\":\"_initialSupply\",\"type\":\"uint256\"}],\"name\":\"constructor\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[{\"name\":\"_owner\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"name\":\"balance\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]",
"origin_address": "TJmmqjb1DK9TTZbQXzRQ2AuA94z4gKAPFh",
"origin_energy_limit": 10000000,
"contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"code_hash": "a1b2c3d4e5f6789012345678901234567890123456789012345678901234567890"
}

Unverified Contract#

{
"bytecode": "608060405234801561001057600080fd5b506004361061017357600035...",
"origin_address": "TJmmqjb1DK9TTZbQXzRQ2AuA94z4gKAPFh",
"origin_energy_limit": 5000000,
"contract_address": "TAbCdEfGhIjKlMnOpQrStUvWxYz123456789",
"code_hash": "b2c3d4e5f6789012345678901234567890123456789012345678901234567890a1"
}

Contract Not Found#

{}

Common Use Cases#

1. Contract Explorer#

class TronContractExplorer {
constructor(apiKey) {
this.analyzer = new TronContractAnalyzer(apiKey);
}

async exploreContract(contractAddress) {
try {
const contractInfo = await this.analyzer.getContractInfo(contractAddress);

if (!contractInfo.exists) {
return { error: 'Contract not found' };
}

return {
basicInfo: {
address: contractInfo.address,
name: contractInfo.name,
creator: contractInfo.creator,
isVerified: contractInfo.isVerified,
standard: contractInfo.analysis.isToken
},
codeInfo: {
bytecodeSize: contractInfo.analysis.bytecodeSize,
codeHash: contractInfo.codeHash,
hasProxy: contractInfo.analysis.isProxy
},
interface: {
functionCount: contractInfo.analysis.functionCount,
eventCount: contractInfo.analysis.eventCount,
viewFunctions: contractInfo.functions.filter(f => f.isView).length,
writeFunctions: contractInfo.functions.filter(f => !f.isView).length,
payableFunctions: contractInfo.functions.filter(f => f.isPayable).length
},
security: {
features: contractInfo.analysis.securityFlags,
hasPayableFunctions: contractInfo.analysis.hasPayableFunctions,
hasConstructor: contractInfo.analysis.hasConstructor
}
};
} catch (error) {
return { error: error.message };
}
}
}

Performance Tips#

  1. Cache Contract Data - Contract information rarely changes, cache for hours
  2. Batch Requests - Check multiple contracts efficiently
  3. ABI Parsing - Parse and cache ABI data for reuse
  4. Selective Loading - Only fetch detailed analysis when needed

Need help? Contact our support team or check the TRON documentation.