seismic-viem / signedReadContract
Function: signedReadContract()
function signedReadContract<TChain, TAccount, TAbi, TFunctionName, TArgs>(
client,
parameters
): Promise<ReadContractReturnType>Defined in: packages/seismic-viem/src/contract/read.ts:117
Executes a signed read operation on a smart contract.
A signed read is an operation unique to Seismic's blockchain.
In Ethereum, users can make an eth_call and specify any from address.
However Seismic restricts this feature: any eth_call made to Seismic
will have the from address overridden to zero. We do this so contract
developers can check against msg.sender inside non-transactions knowing
that these calls will not be spoofed
To make a read that specifies a from address on Seismic, use signed reads. Essentially a signed read sends a signed, raw transaction to the eth_call endpoint. The msg.sender for the call is set to the transaction's signer
Example
const result = await signedReadContract(client, {
abi: myContractAbi,
functionName: 'getBalance',
args: ['0x1234...'],
address: '0x5678...',
})
console.log('Balance:', result)Type Parameters
• TChain extends undefined | Chain
• TAccount extends Account
• TAbi extends Abi | readonly unknown[]
• TFunctionName extends string
• TArgs extends unknown
Parameters
client
ShieldedWalletClient<Transport, TChain, TAccount>
The client used to execute the signed read operation. Must be a ShieldedPublicClient or ShieldedWalletClient.
parameters
SignedReadContractParameters<TAbi, TFunctionName, TArgs>
The parameters for the read operation, including:
abi(Abi) - The contract's ABI.functionName(string) - The name of the function to call.args(array) - The arguments for the function.address(Hex) - The contract's address on the blockchain.- Additional options for customizing the call request.
Returns
Promise<ReadContractReturnType>
A promise that resolves to the response from the contract.
Throws
If the account is not specified for the operation.
Remarks
- If no
accountis specified in the parameters, the function defaults to using a standard read operation (readContract). - Encodes the ABI parameters and function selector for shielded calls.
- Uses
signedCallto securely sign and send the request. - The
datareturned by the contract call is decoded based on the provided ABI.