BlockchainContractValue (for Ethereum)
BlockchainContractValue[caddr]
gets the result obtained from a contract containing a Wolfram expression at Ethereum blockchain address caddr.
BlockchainContractValue[caddr,prop]
gets the property prop of the result obtained from a contract containing a Wolfram expression with address caddr.
BlockchainContractValue[caddr,func]
calls the function func of a contract with address caddr.
BlockchainContractValue[caddr,assoc]
calls a contract with address caddr with the properties defined in Association assoc.
Details
- Gives basic information about an Ethereum contract. By default, it targets the state of the latest block.
- BlockchainContractValue can access the Ethereum mainnet (default) and testnet (Sepolia). To specify these networks, use the BlockchainBase option.
- BlockchainContractValue extracts a contract from the Ethereum blockchain, then runs the specified function in it. It cannot write data to a blockchain; this requires BlockchainTransactionSubmit.
- BlockchainContractValue[caddr,func] calls a contract function where func must be a Typed expression defining the name of the function and the output data type.
- BlockchainContractValue[caddr,assoc] calls a contract with additional parameters where association assoc must have the following property:
-
"Function" Typed expression defining the function to call - Additionally, the association assoc can also have the following properties:
-
"Inputs" input parameters of the function to call "Sender" address of the sender that is calling the contract "BlockNumber" block number associated to a specific state of the blockchain - If a particular function does not successfully evaluate in the contract at a given address, BlockchainContractValue returns Missing["NoResult"].
Examples
open all close allBasic Examples (5)
Call the functions name, symbol and decimals, given an address:
address = "f230b790E05390FC8295F4d3F60332c93BEd42e2";BlockchainContractValue[address, Typed["name", "string"], BlockchainBase -> {"Ethereum", "Mainnet"}]BlockchainContractValue[address, Typed["symbol", "string"], BlockchainBase -> {"Ethereum", "Mainnet"}]BlockchainContractValue[address, Typed["decimals", "uint256"], BlockchainBase -> {"Ethereum", "Mainnet"}]Get the result of a contract containing a Wolfram expression that was deployed in the past:
address = "cEf2Ba8C04343566867d1c3e5948efE4aC800E7b";BlockchainContractValue[address, "Result", BlockchainBase -> {"Ethereum", "Testnet"}]Verify the total supply of OmiseGo tokens using its address:
omgtoken = First[BlockchainTokenData["OMGToken", "TokenAddress", BlockchainBase -> {"Ethereum", "Mainnet"}]]BlockchainContractValue[omgtoken, Typed["totalSupply", "uint256"], BlockchainBase -> {"Ethereum", "Mainnet"}]Check the balance of OMG tokens of a certain holder:
omgtoken = First[BlockchainTokenData["OMGToken", "TokenAddress", BlockchainBase -> {"Ethereum", "Mainnet"}]]sender = RandomChoice[First[BlockchainTokenData["OMGToken", "TransferList", BlockchainBase -> "Ethereum"]]]["Sender"]BlockchainContractValue[omgtoken, <|"Function" -> Typed["balanceOf", "address" -> "uint256"], "Inputs" -> sender|>, BlockchainBase -> {"Ethereum", "Mainnet"}]Check the balance of the holder when the block 6000000 was mined:
BlockchainContractValue[omgtoken, <|"Function" -> Typed["balanceOf", "address" -> "uint256"], "Inputs" -> sender, "BlockNumber" -> 6000000|>, BlockchainBase -> {"Ethereum", "Mainnet"}]Check the auction of CryptoKitty with Token ID 883551 during sale period:
BlockchainContractValue["b1690C08E213a35Ed9bAb7B318DE14420FB57d8C", <|"Function" -> Typed["getAuction", "uint256" -> {"address", "uint256", "uint256", "uint256", "uint256"}], "Inputs" -> 883551|>, BlockchainBase -> {"Ethereum", "Mainnet"}]Options (2)
BlockchainBase (2)
Mainnet (1)
See Also
Blockchains: BlockchainTransaction BlockchainTokenData BlockchainData BlockchainBlockData BlockchainTransactionData
Related Guides
History
Introduced in 2019 (12.0)
Text
Wolfram Research (2019), BlockchainContractValue, Wolfram Language function, https://reference.wolfram.com/language/ref/blockchain/BlockchainContractValue-Ethereum.html.
CMS
Wolfram Language. 2019. "BlockchainContractValue." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/blockchain/BlockchainContractValue-Ethereum.html.
APA
Wolfram Language. (2019). BlockchainContractValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/blockchain/BlockchainContractValue-Ethereum.html
BibTeX
@misc{reference.wolfram_2026_blockchaincontractvalue, author="Wolfram Research", title="{BlockchainContractValue}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/blockchain/BlockchainContractValue-Ethereum.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_blockchaincontractvalue, organization={Wolfram Research}, title={BlockchainContractValue}, year={2019}, url={https://reference.wolfram.com/language/ref/blockchain/BlockchainContractValue-Ethereum.html}, note=[Accessed: 13-June-2026]}