Is there a way to read the Configurable Constants from a contract using typescript or do those need to be made specifically available in a function?
Thanks!
Is there a way to read the Configurable Constants from a contract using typescript or do those need to be made specifically available in a function?
Thanks!
Hey @xpluscal
Will these be the default configurables, or ones that you have set dynamically?
These are configurables that are set upon deployment.
@xpluscal Interactions with a deployed contract happen via functions, so you’d have to make it available via a function.
If you have access to the ABI spec for that contract you can decode the values that are at the given memory range, but without that ABI there’s no way to tell what’s what.
We’re working on a service that would allow you to publicize and fetch configurables, but right now your best bet is to get it from whomever deployed the contract you want the ABI for.
Well @IGI-111 its our own contracts so yes we have the ABI - can you explain how we would read it?
The docs are focused on setting the configurables so I’m not sure we have an easy function in the SDK to read a binary’s existing ones.
However, fundamentally, all that needs to be done is checking the offset defined in the binary:
"configurables": [
{
"name": "A",
"concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0",
"offset": 480
}
]
and then figuring out what the type is, here, u64
:
{
"type": "u64",
"concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
}
With the type you should be able to tell how many encoded bytes you need to read and then decode them using the SDK’s decoder.
If you don’t need to automate this, you can just use forc parse-bytecode
with this offset and go read the encoded value.
great thanks. We’d actually love to automate and put it in our SDK instead of polluting the contracts then