Smart Contract Endpoints
Get Contract
Returns metadata about a specific smart contract deployed on a given blockchain. This is typically used to inspect the contract address, deployment information, version, and VM/runtime details.
Request
GET /blockchains/{blockchainId}/contracts/{address}
For a node running on https://tn-w-1.uledger.net/, the full URL is:https://tn-w-1.uledger.net//blockchains/{blockchainId}/contracts/{address}
Path parameters
blockchainId– The blockchain identifier (one of the values returned byGET /blockchains).address– The on-chain contract address to inspect.
Response
The response contains contract metadata. Exact fields depend on the node and VM configuration, but commonly include:
blockchainId– ID of the blockchain where the contract is deployed.address– Contract address.creator– Address that deployed the contract (if tracked).deploymentTxId– Transaction ID that created the contract.codeHash– Hash of the contract code or artifact.vmType– Contract VM/runtime type.version– Contract version, if versioning is enabled.status– Current contract status (e.g.ACTIVE,PAUSED,UPGRADED).metadata– Optional additional metadata defined by your deployment.
Example response
{
"blockchainId": "{blockchainId}",
"address": "{contractAddress}",
"creator": "{creatorAddress}",
"deploymentTxId": "{deploymentTransactionId}",
"codeHash": "c5b21c4e8f6c4d7e8f3d...",
"vmType": "uledgervm-v1",
"version": 3,
"status": "ACTIVE",
"metadata": {
"name": "ExampleContract",
"description": "Demo contract used for documentation",
"tags": ["demo", "test"]
}
}
- cURL
curl -X GET -L "https://tn-w-1.uledger.net//blockchains/{blockchainId}/contracts/{address}" | jq
// Using native fetch (Node 18+)
const blockchainId = "{blockchainId}";
const address = "{contractAddress}";
const res = await fetch(
`https://tn-w-1.uledger.net//blockchains/${blockchainId}/contracts/${address}`
);
if (!res.ok) {
throw new Error(`Request failed with status ${res.status}`);
}
const contract = await res.json();
console.log("Contract address:", contract.address);
console.log("Status:", contract.status);
console.log("VM type:", contract.vmType);
import requests
blockchain_id = "{blockchainId}"
address = "{contractAddress}"
resp = requests.get(
f"https://tn-w-1.uledger.net//blockchains/{blockchain_id}/contracts/{address}"
)
resp.raise_for_status()
contract = resp.json()
print("Contract address:", contract["address"])
print("Status:", contract["status"])
print("VM type:", contract["vmType"])
Get Contract State
Returns the current state snapshot of a smart contract on a given blockchain. The structure of the state is contract-defined and typically exposed as a JSON object or key–value map.
Request
GET /blockchains/{blockchainId}/contracts/{address}/state
For a node running on http://my.node1.uledger.io, the full URL is:http://my.node1.uledger.io/blockchains/{blockchainId}/contracts/{address}/state
Path parameters
blockchainId– The blockchain identifier.address– The contract address whose state you want to inspect.
Response
The response contains the latest on-chain state for the contract. The exact shape is determined by the contract, but a typical pattern is:
blockchainId– ID of the chain where the contract lives.address– Contract address.version– Current contract state/version number.state– JSON object representing the contract's state.
Example response
{
"blockchainId": "{blockchainId}",
"address": "{contractAddress}",
"version": 3,
"state": {
"owner": "{ownerAddress}",
"totalSupply": "1000000",
"balances": {
"{ownerAddress}": "750000",
"{otherAddress}": "250000"
},
"paused": false
}
}
- cURL
- Node.js
- Python
curl -X GET -L "http://my.node1.uledger.io/blockchains/{blockchainId}/contracts/{address}/state" | jq
// Using native fetch (Node 18+)
const blockchainId = "{blockchainId}";
const address = "{contractAddress}";
const res = await fetch(
`http://my.node1.uledger.io/blockchains/${blockchainId}/contracts/${address}/state`
);
if (!res.ok) {
throw new Error(`Request failed with status ${res.status}`);
}
const snapshot = await res.json();
console.log("State version:", snapshot.version);
console.log("Contract owner:", snapshot.state.owner);
import requests
blockchain_id = "{blockchainId}"
address = "{contractAddress}"
resp = requests.get(
f"http://my.node1.uledger.io/blockchains/{blockchain_id}/contracts/{address}/state"
)
resp.raise_for_status()
snapshot = resp.json()
print("State version:", snapshot["version"])
print("Contract owner:", snapshot["state"]["owner"])
Get Contract Trace / Logs
Returns the execution trace or logs for a specific contract call, identified by the transaction that invoked the contract. This is useful for debugging and observing emitted events.
Request
GET /blockchains/{blockchainId}/contracts/{address}/trace/{transactionId}
For a node running on http://my.node1.uledger.io, the full URL is:http://my.node1.uledger.io/blockchains/{blockchainId}/contracts/{address}/trace/{transactionId}
Path parameters
blockchainId– The blockchain identifier.address– Contract address that handled the transaction.transactionId– The transaction whose contract execution trace you want.
Response
The response format depends on your node configuration, but a typical structure is:
blockchainId,address,transactionId– Context of the trace.events– Array of contract events/log entries emitted during execution.trace– Optional low-level execution trace information.
Example response
{
"blockchainId": "{blockchainId}",
"address": "{contractAddress}",
"transactionId": "{transactionId}",
"events": [
{
"name": "Transfer",
"timestamp": "2025-11-11T20:25:01Z",
"indexedArgs": {
"from": "{fromAddress}",
"to": "{toAddress}"
},
"data": {
"amount": "1000"
}
},
{
"name": "BalanceUpdated",
"timestamp": "2025-11-11T20:25:01Z",
"data": {
"owner": "{toAddress}",
"newBalance": "26000"
}
}
],
"trace": {
"steps": 42,
"gasUsed": 12345
}
}
- cURL
- Node.js
- Python
curl -X GET -L "http://my.node1.uledger.io/blockchains/{blockchainId}/contracts/{address}/trace/{transactionId}" | jq
// Using native fetch (Node 18+)
const blockchainId = "{blockchainId}";
const address = "{contractAddress}";
const transactionId = "{transactionId}";
const res = await fetch(
`http://my.node1.uledger.io/blockchains/${blockchainId}/contracts/${address}/trace/${transactionId}`
);
if (!res.ok) {
throw new Error(`Request failed with status ${res.status}`);
}
const trace = await res.json();
console.log("Events:", trace.events.length);
console.log("First event name:", trace.events[0]?.name);
import requests
blockchain_id = "{blockchainId}"
address = "{contractAddress}"
transaction_id = "{transactionId}"
resp = requests.get(
f"http://my.node1.uledger.io/blockchains/{blockchain_id}/contracts/{address}/trace/{transaction_id}"
)
resp.raise_for_status()
trace = resp.json()
print("Events:", len(trace["events"]))
if trace["events"]:
print("First event name:", trace["events"][0]["name"])