Contracts

List Contracts

List Contracts

GET https://nchain.provide.services/api/v1/contracts

Returns a list of contracts

Query Parameters

Headers

[
    {
        "id": "0ae457ce-da63-44ca-8de6-07fcd950c7bc",
        "created_at": "2018-02-09T21:19:10.68508Z",
        "application_id": "b9509412-66cf-4520-a127-3150c991eaf7",
        "organization_id": null,
        "network_id": "9f7a08cb-4d8d-469d-a53a-f39fde5ece41",
        "contract_id": null,
        "transaction_id": "bbfa0213-b471-4a27-a3bd-e2e6cbd40777",
        "name": "ProxyStorage",
        "address": "0x6aDDe452c74a665548995A47C1f9A2ED0314BB8d",
        "type": null,
        "accessed_at": null,
        "pubsub_prefix": "2d21a6e763a3885652a652d29bbe1c3425e6f0dae4eaae549295731e56e0a8b0"
    },
    {
        "id": "a424289f-4596-48bb-90d6-44b44131aa55",
        "created_at": "2018-02-12T08:35:30.501471Z",
        "application_id": "b9509412-66cf-4520-a127-3150c991eaf7",
        "organization_id": null,
        "network_id": "9f7a08cb-4d8d-469d-a53a-f39fde5ece41",
        "contract_id": null,
        "transaction_id": "45289d92-4ebb-4102-b681-4f07b238e4ef",
        "name": "EternalStorage",
        "address": "0x1D3244091336f0486531eEBf4A1E2A4baac524AF",
        "type": null,
        "accessed_at": null,
        "pubsub_prefix": "38c15789ef4111d2ee5430427745f66152e26a3e859162f6d1ed30167966ea62"
    }
]
curl -i \
    -H 'Authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7fSwiZXhwIjpudWxsLCJpYXQiOjE1NTk4Nzg1NzQsImp0aSI6IjYzYTJkY2QzLWI5OTgtNDZjNC1hNzFkLTQ5MjU4YTBhYmEyMyIsInN1YiI6ImFwcGxpY2F0aW9uOmNiMjAzN2Y3LTc5ZmMtNDBmNC05NzIwLWFkYTYzNmRhNDE4MyJ9.NQLm__LbMWor-9GMG0LPcH4yQIbu9Uw70kJfRt1KP64' \
    https://nchain.provide.services/api/v1/contracts
HTTP/2 200
content-type: application/json; charset=UTF-8
access-control-allow-credentials: true
access-control-allow-headers: Accept, Accept-Encoding, Authorization, Cache-Control, Content-Length, Content-Type, Origin, User-Agent, X-CSRF-Token, X-Requested-With
access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS
access-control-allow-origin: *
access-control-expose-headers: X-Total-Results-Count
x-total-results-count: 3

List smart contracts visible to the authorized User or Application.

Query Parameters

Deploy Contract

Deploy Contract

POST https://nchain.provide.services/api/v1/contracts

Deploys a new smart contract to a specified network

Headers

Request Body

{
    "id": "b1d9df94-6f9e-4285-9de7-6072a69784b9",
    "created_at": "2021-08-16T17:25:45.103744333Z",
    "application_id": "de7efe54-642e-4171-91be-0fe0a7cc0977",
    "organization_id": null,
    "network_id": "07102258-5e49-480e-86af-6d0c3260827d",
    "contract_id": null,
    "transaction_id": null,
    "name": "LGT 8.16.2021:1726",
    "address": "0x",
    "type": null,
    "accessed_at": null,
    "pubsub_prefix": "0643876cb2a7c0e27eaf17beb3fec335a271a3c7ba58103dc215f954a88f6072"
}
curl -i \
    -H 'Authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7fSwiZXhwIjpudWxsLCJpYXQiOjE1NTk4Nzg1NzQsImp0aSI6IjYzYTJkY2QzLWI5OTgtNDZjNC1hNzFkLTQ5MjU4YTBhYmEyMyIsInN1YiI6ImFwcGxpY2F0aW9uOmNiMjAzN2Y3LTc5ZmMtNDBmNC05NzIwLWFkYTYzNmRhNDE4MyJ9.NQLm__LbMWor-9GMG0LPcH4yQIbu9Uw70kJfRt1KP64' \
    -H 'Content-Type: application/json' \
    https://nchain.provide.services/api/v1/contracts \
    -d '{
  "application_id":"bca2348c-442f-4c48-99a4-7b3510385e53",
  "network_id":"ef976635-545b-46c6-9576-4e3a893a68e9",
  "name":"Ekho",
  "address":"0x",
  "params":{
    "compiled_artifact":{
      "contractName": "Ekho",
      "abi": [
        {
          "anonymous": false,
          "inputs": [
            {
              "indexed": false,
              "internalType": "bytes",
              "name": "message",
              "type": "bytes"
            }
          ],
          "name": "Ekho",
          "type": "event"
        },
        {
          "inputs": [
            {
              "internalType": "bytes",
              "name": "message",
              "type": "bytes"
            }
          ],
          "name": "broadcast",
          "outputs": [],
          "stateMutability": "nonpayable",
          "type": "function"
        }
      ],
      "bytecode": "0x608060405234801561001057600080fd5b506101c0806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c80630323a8b014610030575b600080fd5b6100e96004803603602081101561004657600080fd5b810190808035906020019064010000000081111561006357600080fd5b82018360208201111561007557600080fd5b8035906020019184600183028401116401000000008311171561009757600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f8201169050808301925050505050505091929192905050506100eb565b005b7fc11b5aba5095eee01588a1b4f1983f055885ce9581af8e25b9fb34220d24eb73816040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014d578082015181840152602081019050610132565b50505050905090810190601f16801561017a5780820380516001836020036101000a031916815260200191505b509250505060405180910390a15056fea26469706673582212209a157717b400c42ec8447983d186638a51c9ee770e53cbfce55399bf1d381f8164736f6c63430006090033",
      "source": "contract Ekho {\n    event Ekho(bytes message);\n    function broadcast(bytes memory message) public {\n        emit Ekho(message);\n    }\n}\n"
    }
  }'
HTTP/2 201
date: Tue, 24 Nov 2020 20:11:08 GMT
content-type: application/json; charset=UTF-8
access-control-allow-credentials: true
access-control-allow-headers: Accept, Accept-Encoding, Authorization, Cache-Control, Content-Length, Content-Type, Origin, User-Agent, X-CSRF-Token, X-Requested-With
access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS
access-control-allow-origin: *
access-control-expose-headers: X-Total-Results-Count

Deploy a smart contract to a specific Network.

Retrieve Contract Details

Get Contract Detail

GET https://nchain.provide.services/api/v1/contracts/:id

Retrieves detailed information for the specified contract

Path Parameters

Headers

{
    "id": "faa15475-a5a8-42d2-b2ba-da6650e71eb2",
    "created_at": "2021-08-16T17:35:47.963477Z",
    "application_id": "de7efe54-642e-4171-91be-0fe0a7cc0977",
    "organization_id": null,
    "network_id": "07102258-5e49-480e-86af-6d0c3260827d",
    "contract_id": 0x,
    "transaction_id": null,
    "name": "LGT 8.16.2021:1729",
    "address": "",
    "type": null,
    "accessed_at": null,
    "pubsub_prefix": "9cbcde07ff13a96c484a42a467d57560e3f3515d9eec39c9973ea7c6f9ed5452"
}
curl -i \
    -H 'Authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7fSwiZXhwIjpudWxsLCJpYXQiOjE1NTk4Nzg1NzQsImp0aSI6IjYzYTJkY2QzLWI5OTgtNDZjNC1hNzFkLTQ5MjU4YTBhYmEyMyIsInN1YiI6ImFwcGxpY2F0aW9uOmNiMjAzN2Y3LTc5ZmMtNDBmNC05NzIwLWFkYTYzNmRhNDE4MyJ9.0LsVj7oTF0KjwbcUhg9a-fQRWB7cGzKJxLIANeX2cWE' \
    https://nchain.provide.services/api/v1/contracts/4440bc2b-8213-4939-b306-0ba838709dc5
HTTP/2 200
date: Sun, 10 Jun 2019 03:57:22 GMT
content-type: application/json; charset=UTF-8
access-control-allow-credentials: true
access-control-allow-headers: Accept, Accept-Encoding, Authorization, Cache-Control, Content-Length, Content-Type, Origin, User-Agent, X-CSRF-Token, X-Requested-With
access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS
access-control-allow-origin: *
access-control-expose-headers: X-Total-Results-Count

Retrieve Contract details.

URL Parameters

Execute Contract

Construct and execute a specific method in a smart contract.

Execution Resulting in Transaction Broadcast

The API returns 202 Accepted if the contract execution will broadcast a Transaction to the network and returns a ref, which is an identifier you may use to ask for the execution status of the Transaction.

Execute Contract

POST https://nchain.provide.services/api/v1/contracts/:id/execute

Construct and execute a specific method in a smart contract

Path Parameters

Headers

{
    "confidence": null,
    "ref": "e1680c3b-9fad-48df-9265-e3b07a390260"
}
# Execution Resulting in Transaction Broadcast
curl -i \
     -H 'authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7fSwiZXhwIjpudWxsLCJpYXQiOjE1NTk4Nzg1NzQsImp0aSI6IjYzYTJkY2QzLWI5OTgtNDZjNC1hNzFkLTQ5MjU4YTBhYmEyMyIsInN1YiI6ImFwcGxpY2F0aW9uOmNiMjAzN2Y3LTc5ZmMtNDBmNC05NzIwLWFkYTYzNmRhNDE4MyJ9.0LsVj7oTF0KjwbcUhg9a-fQRWB7cGzKJxLIANeX2cWE' \
    -H 'content-type: application/json' \
     https://nchain.provide.services/api/v1/contracts/3b9fe62e-5da7-43dc-838f-3cfa1421ed0f/execute \
     -d '{
  "method": "send",
  "params": [
    "123-456-789",
    "some.random.topic",
    "987-654-321",
    "default.topic",
    "2.0",
    "BOL",
    "{}"
  ],
  "value": 0,
  "account_id": "e6ef498b-589e-4514-9924-278b7bd6e3de"
}'
HTTP/2 202
date: Sun, 10 Jun 2019 04:15:41 GMT
content-type: application/json; charset=UTF-8
access-control-allow-credentials: true
access-control-allow-headers: Accept, Accept-Encoding, Authorization, Cache-Control, Content-Length, Content-Type, Origin, User-Agent, X-CSRF-Token, X-Requested-With
access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS
access-control-allow-origin: *
access-control-expose-headers: X-Total-Results-Count

Execution Resulting in Read Operation

The API returns 200 OK and a response JSON element if the contract execution was an attempt to read data from the network.

# Execution Resulting in Read Operation
curl -i \
     -H 'authorization: bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7fSwiZXhwIjpudWxsLCJpYXQiOjE1NTk4Nzg1NzQsImp0aSI6IjYzYTJkY2QzLWI5OTgtNDZjNC1hNzFkLTQ5MjU4YTBhYmEyMyIsInN1YiI6ImFwcGxpY2F0aW9uOmNiMjAzN2Y3LTc5ZmMtNDBmNC05NzIwLWFkYTYzNmRhNDE4MyJ9.0LsVj7oTF0KjwbcUhg9a-fQRWB7cGzKJxLIANeX2cWE' \
    -H 'content-type: application/json' \
     https://nchain.provide.services/api/v1/contracts/3b9fe62e-5da7-43dc-838f-3cfa1421ed0f/execute \
     -d '{"account_id": "63b15ede-318b-45be-a7ba-bf965bbd0c2e", "method": "ipfs_fields", "params": [], "value": 0}'
HTTP/2 200
date: Sun, 10 Jun 2019 04:15:04 GMT
content-type: application/json; charset=UTF-8
access-control-allow-credentials: true
access-control-allow-headers: Accept, Accept-Encoding, Authorization, Cache-Control, Content-Length, Content-Type, Origin, User-Agent, X-CSRF-Token, X-Requested-With
access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS
access-control-allow-origin: *
access-control-expose-headers: X-Total-Results-Count

Request Parameters

URL Parameters

Last updated