Contracts
GET /explorer/contract/{address}
Returns information about a Tezos smart contract. For balance details call the explorer account endpoint using the contracts KT1 address.
- Schema
- Response
- Example
Field | Description |
---|---|
account_id uint64 | Id of the related account. |
address hash | Contract address. |
creator hash | Creator account (called manager before Babylon. |
baker hash | Baker the contract delegates to (may be empty). |
storage_size int64 | Storage size allocated in bytes. |
storage_paid int64 | Storage bytes paid for in bytes. |
storage_burn money | Total value burned for storage allocations. |
total_fees_used money | Total sum of fees accrued as tx receiver. |
first_seen int64 | Block height of account creation. |
last_seen int64 | Block height of last activity. |
delegated_since int64 | Block height of most recent delegation. |
first_seen_time datetime | Block time of account creation. |
last_seen_time datetime | Block time of last activity. |
n_calls_in int64 | Lifetime total number of successful calls received. |
n_calls_out int64 | Lifetime total number of successful internal calls sent. |
n_calls_failed int64 | Lifetime total number of calls failed. |
bigmaps object | Named bigmaps owned by this contract, map between annotation used in storage spec and bigmap id. |
iface_hash bytes | Short hash to uniquely identify the contract interface, first 8 bytes of the SHA256 hash over binary encoded Michelson script parameters. |
code_hash bytes | Short hash to uniquely identify the contract code, first 8 bytes of the SHA256 hash over binary encoded Michelson script code. |
storage_hash bytes | Short hash to uniquely identify the contract code, first 8 bytes of the SHA256 hash over binary encoded Michelson storage. |
call_stats object | Per-entrypoint call statistics, as named key/value pairs. |
features array | Michelson features used by this contract. Any of account_factory , contract_factory , set_delegate , lambda , transfer_tokens , chain_id , ticket , sapling , view , global_constant , timelock . |
interfaces array | Standard interfaces implemented by this contract. Any of MANAGER , SET_DELEGATE , TZIP-005 , TZIP-007 , TZIP-012 (list may be extended). |
{
"account_id": 818761,
"address": "KT1Puc9St8wdNoGtLiD2WXaHbWU7styaxYhD",
"creator": "tz1P7A3YFgeSsGgopKN9vUU86W3psgTMdtcJ",
"baker": "tz1WCd2jm4uSt4vntk4vSuUWoZQGhLcDuR9q",
"storage_size": 89,
"storage_paid": 35957,
"storage_burn": 26.228,
"total_fees_used": 148.058555,
"first_seen": 1149672,
"last_seen": 1855764,
"first_seen_time": "2020-09-29T16:18:45Z",
"last_seen_time": "2021-11-11T22:15:18Z",
"n_calls_in": 5909,
"n_calls_out": 8810,
"n_calls_failed": 20,
"bigmaps": {
"accounts": 124
},
"iface_hash": "cf9361e19e152667",
"code_hash": "666dcc0163791250",
"storage_hash": "f078cbd9d26e6f66",
"call_stats": {
"addLiquidity": 641,
"approve": 1,
"default": 0,
"removeLiquidity": 250,
"setBaker": 0,
"setManager": 0,
"tokenToToken": 22,
"tokenToXtz": 2631,
"updateTokenPool": 1,
"updateTokenPoolInternal": 1,
"xtzToToken": 2362
},
"features": [
"set_delegate",
"transfer_tokens"
],
"interfaces": []
}
curl https://api.tzpro.io/explorer/contract/KT1Puc9St8wdNoGtLiD2WXaHbWU7styaxYhD
import (
"context"
"github.com/trilitech/tzgo/tezos"
"github.com/trilitech/tzpro-go/tzpro"
)
contract, err := tzpro.DefaultClient.Contract.Get(
context.Background(),
tezos.MustParseAddress("KT1Puc9St8wdNoGtLiD2WXaHbWU7styaxYhD"),
tzpro.NoQuery,
)
Contract Scripts​
GET /explorer/contract/{address}/script
Returns the native Michelson JSON encoding of the deployed smart contract code as well as type specifications for call parameters, storage and bigmaps. Also contains decoded entrypoints and unfolded storage type.
Entrypoint names are extracted from type annotations and appear without prefix @
. In rare cases when the entrypoint name is missing we use the convention @entrypoint_<num>
, or if duplicate we suffix the name with a counter <name>_<num>
.
- Schema
- Response
- Example
Field | Description |
---|---|
script object | Native Micheline primitives (optional, use prim=1 ). |
storage_type object | Typedef for contract storage. |
entrypoints object | List of named entrypoints. |
entrypoints.$.id int64 | Position of the entrypoint in the Michelson parameter tree. |
entrypoints.$.branch string | Path of left (L) or right (R) branches to reach the entrypoint's code in the Michelson code tree. |
entrypoints.$.call string | Annotated name of the entrypoint. |
entrypoints.$.type polymorph | Array of typedef for entrypoint arguments. |
entrypoints.$.prim object | Native Micheline primitives (optional, use prim=1 ). |
views object | List of named on-chain views. |
views.$.name string | Name of the view. |
views.$.type object | Array of typedefs for view input and return arguments. |
views.$.code array | Native Micheline primitives for the Michelson script that implements the view (optional, use prim=1 ). |
views.$.prim object | Native Micheline primitives for the entire view (optional, use prim=1 ). |
// ...
{
"script": {
"code": [
//...
],
"storage": {
// ...
},
},
"storage_type": {
"name": "storage",
"type": "struct",
"args": [{
// ...
}]
},
"entrypoints": {
"approve": {
"id": 0,
"name": "approve",
"branch": "/L/L/L",
"type": [{
"name": "spender",
"type": "address"
},{
"name": "allowance",
"type": "nat"
},{
"name": "currentAllowance",
"type": "nat"
}],
"prim": {
// ...
}
},
//...
},
"views": {
// ...
}
},
// ...
curl "https://api.tzpro.io/explorer/contract/KT1Puc9St8wdNoGtLiD2WXaHbWU7styaxYhD/script?prim=1"
import (
"context"
"github.com/trilitech/tzgo/tezos"
"github.com/trilitech/tzpro-go/tzpro"
)
script, err := tzpro.DefaultClient.Contract.GetScript(
context.Background(),
tezos.MustParseAddress("KT1Puc9St8wdNoGtLiD2WXaHbWU7styaxYhD"),
tzpro.WithPrim(),
)
Contract Storage​
GET /explorer/contract/{address}/storage
Returns the most recent or a historic version of the contracts storage. Supports
- historic values when using
block
(int64|hash) - metadata about the contract and most recent update time/block with
meta=1
- native Micheline primitives
prim=1
- unpacking of packed data with
unpack=1
- Schema
- Response
- Example
Field | Description |
---|---|
meta object | Metadata for the current storage entry (optional, use meta=1 ). |
meta.contract hash | Owner contract. |
meta.time datetime | Update timestamp. |
meta.height int64 | Update height. |
meta.block hash | Block hash of latest update. |
value object | Unfolded storage using type annotations. |
prim object | Native Micheline primitives (optional, use prim=1 ). |
{
"value": {
"accounts": "124",
"freezeBaker": false,
"lqtTotal": "55431856030",
"manager": "KT1B5VTw8ZSMnrjhy337CEvAm4tnT8Gu8Geu",
"selfIsUpdatingTokenPool": false,
"tokenAddress": "KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9",
"tokenPool": "1494861",
"xtzPool": "1191482"
},
"prim": {
// ...
}
}
curl "https://api.tzpro.io/explorer/contract/KT1Puc9St8wdNoGtLiD2WXaHbWU7styaxYhD/storage?prim=1"
import (
"context"
"github.com/trilitech/tzgo/tezos"
"github.com/trilitech/tzpro-go/tzpro"
)
// use default Mainnet client
storage, err := tzpro.DefaultClient.Contract.GetStorage(
context.Background(),
tezos.MustParseAddress("KT1Puc9St8wdNoGtLiD2WXaHbWU7styaxYhD"),
tzpro.WithPrim(),
)
Contract Calls​
GET /explorer/contract/{address}/calls
Returns contract calls (transactions) sent to the contract with embedded parameters, storage and bigmap updates. Supports
- metadata with
meta=1
- native Micheline primitives
prim=1
- unpacking of packed data withh
unpack=1
- listing of newer updates with
since
(int64|hash) - ordering of calls with
order
(asc|desc) - filtering by
entrypoint
(int64|string) using id, name or branch
- Schema
- Response
- Example
Field | Description |
---|---|
entrypoint string | Named entrypoint used in call params, e.g. 'default' or 'entrypoint_00. |
branch string | Path of left (L) or right (R) branches to reach the entrypoint's code in the Michelson code tree. |
call string | Name of the executed entrypoint. This is useful if call parameters reference a different entrypoint name, but include a sub-tree of primitives that unpacks to this concrete entrypoint. |
id int64 | Position of the entrypoint in the Michelson parameter tree. |
value object | Call parameters in order of type definition. |
prim object | Native Micheline primitives (optional, use prim=1 ). |
// ...
"parameters": {
"entrypoint": "addLiquidity",
"call": "addLiquidity",
"branch": "/L/L/R",
"id": 1,
"value": {
"addLiquidity": {
"deadline": "2020-09-30T18:30:44.002Z",
"maxTokensDeposited": "6000000",
"minLqtMinted": "1",
"owner": "tz1fSkEwBCgTLas8Y82SYpEGW9aFZPBag8uY"
}
},
"prim": {
// ...
},
},
"big_map_diff": {
// ...
},
"storage": {
// ...
}
// ...
curl "https://api.tzpro.io/explorer/contract/KT1Puc9St8wdNoGtLiD2WXaHbWU7styaxYhD/calls?prim=1"
import (
"context"
"github.com/trilitech/tzgo/tezos"
"github.com/trilitech/tzpro-go/tzpro"
)
// use default Mainnet client
calls, err := tzpro.DefaultClient.Contract.ListCalls(
context.Background(),
tezos.MustParseAddress("KT1Puc9St8wdNoGtLiD2WXaHbWU7styaxYhD"),
tzpro.WithPrim(),
)