Polluxchain
  1. Smart Contract
Polluxchain
  • Background
  • API key
    • Rate Limits
    • Security Settings
  • Full Node HTTP API
    • Address Utilities
      • ValidateAddress
    • Transactions
      • BroadcastTransaction
      • BroadcastHex
      • CreateTransaction
    • Accounts
      • CreateAccount
      • GetAccount
      • UpdateAccount
      • AccountPermissionUpdate
      • GetAccountBalance
    • Account Resources
      • GetAccountResource
      • GetAccountNet
      • FreezeBalance
      • UnfreezeBalanceV2
      • CancelAllUnfreezeV2
      • DelegateResource
      • UnDelegateResource
      • WithdrawExpireUnfreeze
      • GetAvailableUnfreezeCount
      • GetCanWithdrawUnfreezeAmount
      • GetCanDelegatedMaxSize
      • GetDelegatedResourceV2
      • GetDelegatedResourceAccountIndexV2
    • Query The Network
      • GetBlock
      • GetBlockByNum
      • GetBlockById
      • GetBlockByLatestNum
      • GetBlockByLimitNext
      • GetNowBlock
      • GetTransactionById
      • GetTransactionInfoById
      • GetTransactionInfoByBlockNum
      • ListNodes
      • GetNodeInfo
      • GetChainParameters
      • GetBlockBalance
      • GetEnergyPrices
      • GetBandwidthPrices
      • GetBurnTRX
      • GetApprovedList
    • Smart Contract
      • GetContract
        POST
      • GetContractInfo
        POST
      • TriggerSmartContract
        POST
      • TriggerConstantContract
        POST
      • DeployContract
        POST
      • UpdateSetting
        POST
      • UpdateEnergyLimit
        POST
      • ClearAbi
        POST
      • EstimateEnergy
        POST
    • Voting & SRs
      • ListWitnesses
      • CreateWitness
      • UpdateWitness
      • GetBrokerage
      • UpdateBrokerage
      • VoteWitnessAccount
      • GetReward
      • WithdrawBalance
      • GetNextMaintenanceTime
    • Proposals
      • ListProposals
      • GetProposalById
      • ProposalCreate
      • ProposalApprove
      • ProposalDelete
    • Pending pool
      • GetTransactionListFromPending
      • GetTransactionFromPending
      • GetPendingSize
  • Full Node Solidity HTTP API
    • Transactions
      • GetTransactionById
      • GetTransactionInfoById
      • GetTransactionInfoByBlockNum
      • GetTransactionCountByBlockNum
    • Blocks
      • GetBlock
      • GetNowBlock
      • GetBlockByNum
      • GetBlockById
      • GetBlockByLatestNum
      • GetBlockByLimitNext
    • Account Resources
      • GetAccount
      • GetDelegatedResource
      • GetDelegatedResourceAccountIndex
      • GetCanDelegatedMaxSize
      • GetCanWithdrawUnfreezeAmount
      • GetDelegatedResourceAccountIndexV2
      • GetAvailableUnfreezeCount
    • Node & Chain
      • GetNodeInfo
      • GetBurnPOX
    • Smart Contracts
      • TriggerConstantContract
      • EstimateEnergy
    • Voting & SRs
      • ListWitnesses
      • GetReward
      • GetBrokerage
  • Full Node JSON-RPC API
    • Overview
    • buildTransaction
    • eth
      • eth_accounts
      • eth_blockNumber
      • eth_call
      • eth_chainId
      • eth_coinbase
      • eth_estimateGas
      • eth_gasPrice
      • eth_getBalance
      • eth_getBlockByHash
      • eth_getBlockByNumber
      • eth_getBlockTransactionCountByHash
      • eth_getBlockTransactionCountByNumber
      • eth_getCode
      • eth_getStorageAt
      • eth_getTransactionByBlockHashAndIndex
      • eth_getTransactionByBlockNumberAndIndex
      • eth_getTransactionByHash
      • eth_getTransactionReceipt
      • eth_getWork
      • eth_protocolVersion
      • eth_syncing
      • eth_newFilter
      • eth_newBlockFilter
      • eth_getFilterChanges
      • eth_getFilterLogs
      • eth_uninstallFilter
      • eth_getLogs
    • net
      • net_listening
      • net_peerCount
      • net_version
    • web3
      • web3_clientVersion
      • web3_sha3
  • PolluxWeb
    • address
    • createAccount
    • createRandom
    • fromAscii
    • fromDecimal
    • fromMnemonic
    • fromUtf8
    • getEventByTransactionID
    • getEventResult
    • isAddress
    • isConnected
    • setHeader
    • setDefaultBlock
    • setPrivateKey
    • setAddress
    • sha3
    • toAscii
    • toBigNumber
    • toDecimal
    • toHex
    • toRAM
    • toUtf8
    • BigNumber
    • polluxweb.trx
      • getAccount
      • getAccountResources
      • getApprovedList
      • getAvailableUnfreezeCount
      • getBalance
      • getBandwidth
      • getBlock
      • getBlockByHash
      • getBlockByNumber
      • getBlockRange
      • getBlockTransactionCount
      • getBrokerage
      • getCanDelegatedMaxSize
      • getCanWithdrawUnfreezeAmount
      • getChainParameters
      • getConfirmedTransaction
      • getContract
      • getCurrentBlock
      • getDelegatedResourceV2
      • getDelegatedResourceAccountIndexV2
      • getExchangeByID
      • getNodeInfo
      • getReward
      • getTokenByID
      • getTokenFromID
      • getTokenListByName
      • getTokensIssuedByAddress
      • getTransaction
      • getTransactionFromBlock
      • getTransactionInfo
      • getUnconfirmedBalance
      • getUnconfirmedBrokerage
      • getUnconfirmedReward
      • listExchanges
      • listExchangesPaginated
      • listNodes
      • listProposals
      • listSuperRepresentatives
      • listTokens
      • sendRawTransaction
      • sendHexTransaction
      • sendToken
      • sendTransaction
      • sign
      • signMessageV1
      • signMessageV2
      • timeUntilNextVoteCycle
      • multiSign
      • verifyMessage
      • verifyMessageV2
      • _signTypedData
      • verifyTypedData
    • polluxweb.transactionBuilder
      • addUpdateData
      • applyForSR
      • cancelUnfreezeBalanceV2
      • createAccount
      • createAsset
      • createProposal
      • createSmartContract
      • createToken
      • delegateResource
      • deleteProposal
      • estimateEnergy
      • extendExpiration
      • freezeBalance
      • freezeBalanceV2
      • injectExchangeTokens
      • purchaseAsset
      • purchaseToken
      • sendAsset
      • sendToken
      • sendTrx
      • tradeExchangeTokens
      • triggerConfirmedConstantContract
      • triggerConstantContract
      • triggerSmartContract
      • undelegateResource
      • unfreezeBalance
      • unfreezeBalanceV2
      • updateSetting
      • updateAccountPermissions
      • updateAsset
      • updateBrokerage
      • updateEnergyLimit
      • updateToken
      • vote
      • voteProposal
      • withdrawBlockRewards
      • withdrawExchangeTokens
      • withdrawExpireUnfreeze
    • poxweb.contract
      • polluxweb.contract.new
      • polluxweb.contract()
      • method.call()
      • method.send()
    • polluxweb.utils
      • transaction.txJsonToPb
      • transaction.txPbToTxID
      • message.hashMessage
  • Pollux CLI
    • Pollux CLI
  1. Smart Contract

TriggerConstantContract

POST
/wallet/triggerconstantcontract
Invoke the readonly function (modified by the view or pure modifier) of a contract for contract data queries; or invoke the non-readonly function of a contract to predict whether the transaction can be successfully executed and estimate the energy consumption; or estimate the energy consumption for contract deployment.
Note:
TriggerConstantContract operation will not generate an on-chain transaction, nor will it change the status of the current node.
For estimating energy:
To estimate the energy consumption of contract deployment, simply pass the bytecode of the contract through the data field.
To estimate the energy consumption of contract calls, call non-read-only methods of contracts.
When using triggerconstantcontract to estimate energy consumption, the energy_used field in the returned value indicates the energy consumption. Therefore, the fee_limit of the transaction can be set to energy_used x energy unit price.
Parameter encoding and decoding example: Parameter and return value encoding and decoding.
Returns
FieldTypeDescription
owner_addressstringAccount address
contract_addressstringContract address
call_valueint64The amount of TRX passed into the contract
datastringOperating parameters
call_token_valueint64The amount of TRC-10 transferred into the contract
token_idint64TRC-10 token id
Conclusion:
The estimated energy consumption: energy_used
The penalty energy consumption: energy_penalty
The basic energy consumption: energy_used - energy_penalty

Request

Body Params application/json
object {0}
Example
{
  "owner_address": "PHqgRM8giN6Nr9DgA1FybUjKFwd79cxhyp",
  "contract_address": "PFHUpUNpmPVTYziBWCMk7kopiTzx9mX56r",
  "function_selector": "balanceOf(address)",
  "parameter": "000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c",
  "visible": true
}

Request samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST '/wallet/triggerconstantcontract' \
--header 'Content-Type: application/json' \
--data-raw '{
  "owner_address": "PHqgRM8giN6Nr9DgA1FybUjKFwd79cxhyp",
  "contract_address": "PFHUpUNpmPVTYziBWCMk7kopiTzx9mX56r",
  "function_selector": "balanceOf(address)",
  "parameter": "000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c",
  "visible": true
}'

Responses

🟢200Success
application/json
Body
object {0}
Examples
{
    "result": {
        "result": true
    },
    "energy_used": 541,
    "constant_result": [
        "00000000000000000000000000000000000000000000000000000001970c956f"
    ],
    "transaction": {
        "ret": [
            {}
        ],
        "visible": true,
        "txID": "d139a8df064439dbb4b918011660db25008bf925285c86bd877ea5e51ff4d047",
        "raw_data": {
            "contract": [
                {
                    "parameter": {
                        "value": {
                            "data": "70a08231000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c",
                            "owner_address": "PHqgRM8giN6Nr9DgA1FybUjKFwd79cxhyp",
                            "contract_address": "PFHUpUNpmPVTYziBWCMk7kopiTzx9mX56r"
                        },
                        "type_url": "type.googleapis.com/protocol.TriggerSmartContract"
                    },
                    "type": "TriggerSmartContract"
                }
            ],
            "ref_block_bytes": "4715",
            "ref_block_hash": "a773bc452f75199a",
            "expiration": 1737542190000,
            "timestamp": 1737542131187
        },
        "raw_data_hex": "0a0247152208a773bc452f75199a40b087d7ecc8325a8e01081f1289010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412540a1541fd49eda0f23ff7ec1d03b52c3a45991c24cd440e12154142a1e39aefa49290f2b3f9ed688d7cecf86cd6e0222470a08231000000000000000000000000a614f803b6fd780986a42c78ec9c7f77e6ded13c70f3bbd3ecc832"
    }
}
Previous
TriggerSmartContract
Next
DeployContract
Built with