This repository was archived by the owner on Feb 9, 2024. It is now read-only.
useink@1.4.0
- Add default caller configuration options
Overview
Most dApps today require a user to connect their wallet before making calls to the blockchain and displaying any UI. This adds friction to users interacting with a product and is a bad user experience. (This is especially true for EVM chains). This PR introduces an optional configuration for developers to set a default caller address that can be used to make calls to contracts before the end user connects a wallet. After a user connects their wallet the connected account will be used instead of the default.
e.g.
Configuration
<UseInkProvider
config={{
dappName: 'Dex',
chains: [RococoContractsTestnet, RococoTestnet, ShibuyaTestnet, Astar, Phala, Aleph],
caller: {
default: '5CXvURDfLfjKvJunsi8cYYUULXbTYUv5YK6h9oHMJUC5ERUT',
aleph: '5HprbfKUFdN4qfweVbgRtqDPHfNtoi8NoWPE45e5bD5AEKiR',
}
}
>
<MyRoutes />
</UseInkProvider>const call = useCall(contract, 'foo');
const alephCall = useCall(contractOnAlephZero, 'foo');
const args = [];
// If the user's wallet is NOT connected then this will call 'foo' with the default address.
// If the user's wallet IS connected then it will use the connected address
call.send(args, { defaultCaller: true });
// If the user's wallet is NOT connected then this will call 'foo' with the Aleph Zero default address.
// If the user's wallet IS connected then it will use the connected address
alephCall.send(args, { defaultCaller: true });This works with useCall, useCallSubscription, useTxPaymentInfo, and useDryRun. This feature does NOT work with useTx, which requires a signature.