starknet-react
starknet-react copied to clipboard
Introduce hooks for low-level contract calls and invocations
There are some use cases which may mandate using the low-level starknet.js
operations callContract
and invokeFunction
. However, today, no hook api exists for them. This is particularly useful in StarkNet where we don't need the full contract signature to call a function.
Examples:
- Rapid prototyping (e.g., only need to call 1 function without providing abi)
- Low-level interactions (e.g., trading/MEV contracts in ethereum mainnet)
- Security testing of contracts
Agree with this. We should add the following hooks:
-
useProviderCall
that has the same behaviour as the current call hook, but callsprovider.callContract
-
useProviderInvoke
that usesprovider.invokeFunction
Another way to do this, change useStarknetCall
to:
function useStarknetCall({ contractOrAddress }: { contractOrAddress?: string | Contract })
If it's a Contract
, then the behaviour is the same as today. If it's a string, then it uses callContract
.
For invoke, I think using useStarknetExecute
is enough?
Is it still open ? I would like to work on this one if possible
Someone else is working on this as part of moving everything to a wagmi-like API.
This is now the default behaviour thanks to starknet.js populateTransaction
.