---
title: "BlockchainContractValue"
language: "en"
type: "Symbol"
summary: "BlockchainContractValue[caddr] gets the storage of a Tezos contract with address caddr. BlockchainContractValue[caddr, annot] gets the storage value annotated with annot from the storage of a Tezos contract with address caddr. BlockchainContractValue[caddr, opList] gets the storage value after applying the list of Michelson pair operations opList to the storage of a Tezos contract with address caddr. BlockchainContractValue[caddr, assoc] gets the storage of a Tezos contract with address caddr with the properties defined in Association assoc."
keywords: 
- tezos
- SmartContract
- contract
- smart contract
- storage value
- storage
- Michelson
- big map
canonical_url: "https://reference.wolfram.com/language/ref/blockchain/BlockchainContractValue-Tezos.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Working with Tezos Blockchains"
    link: "https://reference.wolfram.com/language/guide/Blockchain-Tezos.en.md"
  - 
    title: "Working with Cardano Blockchains"
    link: "https://reference.wolfram.com/language/guide/Blockchain-Cardano.en.md"
related_functions: 
  - 
    title: "BlockchainTransaction"
    link: "https://reference.wolfram.com/language/ref/blockchain/BlockchainTransaction-Tezos.en.md"
  - 
    title: "BlockchainTokenData"
    link: "https://reference.wolfram.com/language/ref/blockchain/BlockchainTokenData-Tezos.en.md"
  - 
    title: "BlockchainData"
    link: "https://reference.wolfram.com/language/ref/blockchain/BlockchainData-Tezos.en.md"
  - 
    title: "BlockchainBlockData"
    link: "https://reference.wolfram.com/language/ref/blockchain/BlockchainBlockData-Tezos.en.md"
  - 
    title: "BlockchainTransactionData"
    link: "https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionData-Tezos.en.md"
---
[EXPERIMENTAL]

# BlockchainContractValue (for Tezos)

BlockchainContractValue[caddr] gets the storage of a Tezos contract with address caddr.

BlockchainContractValue[caddr, annot] gets the storage value annotated with annot from the storage of a Tezos contract with address caddr.

BlockchainContractValue[caddr, opList] gets the storage value after applying the list of Michelson pair operations opList to the storage of a Tezos contract with address caddr.

BlockchainContractValue[caddr, assoc] gets the storage of a Tezos contract with address caddr with the properties defined in Association assoc.

## Details

* Gives information about the storage of a Tezos contract. By default, it targets the state of the latest block.

* ``BlockchainContractValue`` has option ``BlockchainBase`` with default value ``\$BlockchainBase``.

* Possible options for ``BlockchainContractValue`` include:

|                 |         |                                               |
| --------------- | ------- | --------------------------------------------- |
| BlockchainBase  | "Tezos" | the blockchain and network to use             |
| MaxItems        | 20      | the maximum number of big map items to return |

* ``BlockchainContractValue`` will return 1000 big map elements at most.

* ``BlockchainContractValue[caddr]`` returns the storage of a Tezos contract with address ``caddr``.

* ``BlockchainContractValue[caddr, annot]`` returns the annotated storage value where ``annot`` must be a ``String`` expression.

* ``BlockchainContractValue[caddr, opList]`` returns the storage value where ``opList`` must be a ``List`` containing ``Left`` and ``Right`` expressions representing Michelson pair operations.

* If an annotated Michelson pair is returned by ``BlockchainContractValue``, it returns a nested list of associations with the following properties:

|              |                                                         |
| ------------ | ------------------------------------------------------- |
| "Annotation" | annotation of the storage value inside a Michelson pair |
| "Value"      | storage value inside a Michelson pair                   |

* If there is no storage value associated with ``annot`` or ``opList`` in the storage of the contract, ``Missing["NotAvailable"]`` is returned.

* ``BlockchainContractValue[caddr, assoc]`` returns the storage value with additional parameters where ``Association`` ``assoc`` can have the following properties:

|                 |                                                                           |
| --------------- | ------------------------------------------------------------------------- |
| "BlockNumber"   | block number associated to a specific state of the blockchain             |
| "Annotation"    | string used to identify a storage value in a Michelson pair               |
| "OperationList" | list of Left and Right expressions representing Michelson pair operations |
| "KeyHash"       | key hash associated to a Michelson big map element                        |

* If a Michelson big map is returned by ``BlockchainContractValue``, it returns instead a list of associations with the following properties:

|           |                                                    |
| --------- | -------------------------------------------------- |
| "Key"     | key associated to a Michelson big map element      |
| "KeyHash" | key hash associated to a Michelson big map element |
| "Value"   | value associated to a Michelson big map element    |

* When the association ``assoc`` in ``BlockchainContractValue[caddr, assoc]`` contains the ``"KeyHash"`` element, the big map element value corresponding to the specified ``"KeyHash"`` is returned.

---

## Examples (10)

### Basic Examples (6)

Get the storage of the USDtz token contract:

```wl
In[1]:= BlockchainContractValue["KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9", BlockchainBase -> "Tezos"]

Out[1]= {<|"Annotation" -> "ledger", "KeyType" -> <|"prim" -> "address"|>, "Value" -> 36|>, {<|"Annotation" -> "admin", "Value" -> "tz1P19MKNTwB7qxoU47bvsu2c3u54vdM8R4m"|>, {<|"Annotation" -> "paused", "Value" -> False|>, <|"Annotation" -> "totalSupply", "Value" -> 1296285663951|>}}}
```

---

Get the total supply of tokens of the USDtz token contract using an annotation:

```wl
In[1]:= BlockchainContractValue["KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9", "totalSupply", BlockchainBase -> "Tezos"]

Out[1]= 1296285663951
```

---

Get the total supply of tokens of the USDtz token contract using a list of Michelson operation pairs:

```wl
In[1]:= BlockchainContractValue["KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9", {Right, Right, Right}, BlockchainBase -> "Tezos"]

Out[1]= 1296285663951
```

---

Get the total supply of tokens of the USDtz token contract at the block 1000000:

```wl
In[1]:= BlockchainContractValue["KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9", <|"BlockNumber" -> 1000000, "Annotation" -> "totalSupply"|>, BlockchainBase -> "Tezos"]

Out[1]= 236000001
```

---

Get the 20 most recently updated balances from the ledger of the USDtz token contract. The annotated storage value ``"ledger"`` is a big map, so a list of associations will be returned:

```wl
In[1]:= BlockchainContractValue["KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9", "ledger", BlockchainBase -> "Tezos"]//Dataset

Out[1]=
Dataset[{Association["BlockNumber" -> 1507327, "Timestamp" -> DateObject[{2021, 6, 9, 1, 23, 14.}, 
     "Instant", "Gregorian", 0.], "Key" -> "tz1T1u1CET7ek19f5P59vCdjTNFWAscYQ5ct", 
   "KeyHash" -> "expruLudm3yMDrkssfNaRQh1RVHitPFu1jSbd1J6qwAQWs7 ... , 
     "Instant", "Gregorian", 0.], "Key" -> "KT1Tr2eG3eVmPRbymrbU2UppUmKjFPXomGG9", 
   "KeyHash" -> "expruNC6R3Wwykk37ZYJZXq3j4x3SfcYoP54KGZGUNWzwkAKBk2WnR", 
   "Value" -> Association["balance" -> "5834788765", "approvals" -> Association[]]]}]
```

The storage value can also be specified by using a Michelson pair operations list:

```wl
In[2]:= BlockchainContractValue["KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9", <|"OperationList" -> {Left}|>, BlockchainBase -> "Tezos"]//Dataset

Out[2]=
Dataset[{Association["BlockNumber" -> 1507327, "Timestamp" -> DateObject[{2021, 6, 9, 1, 23, 14.}, 
     "Instant", "Gregorian", 0.], "Key" -> "tz1T1u1CET7ek19f5P59vCdjTNFWAscYQ5ct", 
   "KeyHash" -> "expruLudm3yMDrkssfNaRQh1RVHitPFu1jSbd1J6qwAQWs7 ... , 
     "Instant", "Gregorian", 0.], "Key" -> "KT1Tr2eG3eVmPRbymrbU2UppUmKjFPXomGG9", 
   "KeyHash" -> "expruNC6R3Wwykk37ZYJZXq3j4x3SfcYoP54KGZGUNWzwkAKBk2WnR", 
   "Value" -> Association["balance" -> "5834788765", "approvals" -> Association[]]]}]
```

---

Get a specific entry from the ledger of balances of the USDtz token contract:

```wl
In[1]:= BlockchainContractValue["KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9", <|"Annotation" -> "ledger", "KeyHash" -> "expruHyMf4t2ySAEtxfTTBiwV4bRP53rXLWMopohqPjaabi5wzvyAV"|>, BlockchainBase -> "Tezos"]

Out[1]= <|"balance" -> "1494861", "approvals" -> <||>|>
```

### Options (3)

#### BlockchainBase (2)

##### Mainnet (1)

---

Get the storage of a Tezos contract in mainnet:

```wl
In[1]:= BlockchainContractValue["KT1S5iPRQ612wcNm6mXDqDhTNegGFcvTV7vM", BlockchainBase -> {"Tezos", "Mainnet"}]

Out[1]= {{{{<|"Annotation" -> "admins", "Value" -> {"tz1TZERoLXqCytrJBmjdzNrAYie1TQ1c2cHN"}|>, <|"Annotation" -> "allowances", "Value" -> 62|>}, {<|"Annotation" -> "balances", "Value" -> 63|>, <|"Annotation" -> "description", "Value" -> "Aspen Digital Toke ... , "Value" -> "KT19nHqEWZxFFbbDL1b7Y86escgEN7qUShGo"|>}}}, {{<|"Annotation" -> "rules", "Value" -> "KT1KemKUx79keZgFW756jQrqKcZJ21y4SPdS"|>, <|"Annotation" -> "symbol", "Value" -> "ASPD"|>}, <|"Annotation" -> "total_supply", "Value" -> 18000000|>}}
```

##### Testnet (1)

---

Get the storage of a Tezos contract in testnet:

```wl
In[1]:= contract = First[DeleteMissing[Lookup[BlockchainAddressData["tz1YeQkgxvzVroTyMh72DrmNRsyzQfsBmxt8", "TransactionList", BlockchainBase -> {"Tezos", "Testnet"}], "Contract"]]]

Out[1]= "KT1DkHp1HkEb23VtYWx38NipJFYoth771ab8"

In[2]:= BlockchainContractValue[contract, BlockchainBase -> {"Tezos", "Testnet"}]

Out[2]= "hello"
```

#### MaxItems (1)

List the 5 most recently updated big map elements from the ``"royalties"`` big map:

```wl
In[1]:= BlockchainContractValue["KT1Hkg5qeNhfwpKW4fXvq7HGZB9z2EnmCCA9", "royalties", BlockchainBase -> "Tezos", MaxItems -> 5]//Dataset

Out[1]=
Dataset[{Association["BlockNumber" -> 1632551, 
   "Timestamp" -> DateObject[{2021, 8, 23, 17, 25, 56.}, "Instant", "Gregorian", 0.], 
   "Key" -> 222381, "KeyHash" -> "exprv8jTU4YrjSYLWsV2a4LPKDkDpLGWAg7ixHHb9QXLYonhMETmbj", 
   "Value" -> Associa ...  23, 17, 22, 56.}, 
     "Instant", "Gregorian", 0.], "Key" -> 222379, 
   "KeyHash" -> "expruB86WeDPSKVgdokzn2K7jHECp65TypeRpAw3pdyERVVpnw77QY", 
   "Value" -> Association["issuer" -> "tz1iKZSN7CvqQeq9o95pvi2b4Nmg6C4ue2HM", "royalties" -> 100]]}]
```

### Possible Issues (1)

When referencing a storage value, the ``"Annotation"`` and ``"OperationList"`` filters cannot be passed together:

```wl
In[1]:= BlockchainContractValue["KT1LN4LPSqTMS7Sd2CJw4bbDGRkMv2t68Fy9", <|"Annotation" -> "ledger", "OperationList" -> {Right, Right}, "KeyHash" -> "expruHyMf4t2ySAEtxfTTBiwV4bRP53rXLWMopohqPjaabi5wzvyAV"|>, BlockchainBase -> "Tezos"]
```

BlockchainContractValue::bcvdup: The "Annotation" and "OperationList" filters can't be passed together.

```wl
Out[1]= $Failed
```

## See Also

* [`BlockchainTransaction`](https://reference.wolfram.com/language/ref/blockchain/BlockchainTransaction-Tezos.en.md)
* [`BlockchainTokenData`](https://reference.wolfram.com/language/ref/blockchain/BlockchainTokenData-Tezos.en.md)
* [`BlockchainData`](https://reference.wolfram.com/language/ref/blockchain/BlockchainData-Tezos.en.md)
* [`BlockchainBlockData`](https://reference.wolfram.com/language/ref/blockchain/BlockchainBlockData-Tezos.en.md)
* [`BlockchainTransactionData`](https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionData-Tezos.en.md)

## Related Guides

* [Working with Tezos Blockchains](https://reference.wolfram.com/language/guide/Blockchain-Tezos.en.md)
* [Working with Cardano Blockchains](https://reference.wolfram.com/language/guide/Blockchain-Cardano.en.md)

## History

* [Introduced in 2020 (12.2)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn122.en.md)