State Routes

get contracts #

GET /contracts

Returns all the smartcontracts on the Lamden blockchain

Example https://masternode-01.lamden.io/contracts

JSON response #

{
    "contracts": ["contract_1", "contract_2", "contract_3", "etc..." ]
}

get contract code #

GET /contracts/:contract_name

Returns a contract’s python code.

Example https://masternode-01.lamden.io/contracts/currency

JSON response #

{
    "name": "currency",
    "code": "__balances = Hash(default_value=0, contract='currency', name='balances')\n\n\ndef ____(vk: str):\n    __balances[vk] = 288090567\n\n\[email protected]__export('currency')\ndef transfer(amount: float, to: str):\n    assert amount > 0, 'Cannot send negative balances!'\n    sender = ctx.caller\n    assert __balances[sender] >= amount, 'Not enough coins to send!'\n    __balances[sender] -= amount\n    __balances[to] += amount\n\n\[email protected]__export('currency')\ndef balance_of(account: str):\n    return __balances[account]\n\n\[email protected]__export('currency')\ndef allowance(owner: str, spender: str):\n    return __balances[owner, spender]\n\n\[email protected]__export('currency')\ndef approve(amount: float, to: str):\n    assert amount > 0, 'Cannot send negative balances!'\n    sender = ctx.caller\n    __balances[sender, to] += amount\n    return __balances[sender, to]\n\n\[email protected]__export('currency')\ndef transfer_from(amount: float, to: str, main_account: str):\n    assert amount > 0, 'Cannot send negative balances!'\n    sender = ctx.caller\n    assert __balances[main_account, sender\n        ] >= amount, 'Not enough coins approved to send! You have {} and are trying to spend {}'.format(\n        __balances[main_account, sender], amount)\n    assert __balances[main_account] >= amount, 'Not enough coins to send!'\n    __balances[main_account, sender] -= amount\n    __balances[main_account] -= amount\n    __balances[to] += amount\n"
}

get contract methods #

GET /contracts/:contract_name/methods

Returns all exported methods from a smartcontract including each method’s argument name and type.

Example https://masternode-01.lamden.io/contracts/currency/methods

JSON response #

{
    "methods":[
      {
         "name":"transfer",
         "arguments":[
            {
               "name":"amount",
               "type":"float"
            },
            {
               "name":"to",
               "type":"str"
            }
         ]
      },
      {
         "name":"balance_of",
         "arguments":[
            {
               "name":"account",
               "type":"str"
            }
         ]
      },
      {
         "name":"allowance",
         "arguments":[
            {
               "name":"owner",
               "type":"str"
            },
            {
               "name":"spender",
               "type":"str"
            }
         ]
      },
      {
         "name":"approve",
         "arguments":[
            {
               "name":"amount",
               "type":"float"
            },
            {
               "name":"to",
               "type":"str"
            }
         ]
      },
      {
         "name":"transfer_from",
         "arguments":[
            {
               "name":"amount",
               "type":"float"
            },
            {
               "name":"to",
               "type":"str"
            },
            {
               "name":"main_account",
               "type":"str"
            }
         ]
      }
   ]
}

get contract variables #

GET /contracts/:contract_name/variables

Returns all state variables and hashes defined in a smart contract

Example https://masternode-01.lamden.io/contracts/currency/variables

JSON response #

{
    "variables":[],
   "hashes":["balances"]
}
Updated on February 3, 2021