Hello.
How to use useWeb3ExecuteFunction
?
const ShowUniswapObserveValues = () => {
const { data, error, fetch, isFetching, isLoading } = useWeb3ExecuteFunction();
const options = {
abi,
contractAddress: '0xF28c3e812cFE316cA099978C8e4cB53d81b41acF',
functionName: 'getFullName',
params: {
_list: 0,
_name: '0x7465737400000000000000000000000000000000000000000000000000000000'
}
}
return (<div>
{error && <ErrorMessage error={error} />}
<button onClick={() => fetch({ params: options })} disabled={isFetching}>Fetch data</button>
{data && <pre>
{JSON.stringify(data)}
</pre>}
</div>)
}
ABI
ABI
const abi = [
{
inputs: [],
stateMutability: 'nonpayable',
type: 'constructor',
},
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: 'bytes',
name: 'full_name',
type: 'bytes',
},
{
indexed: true,
internalType: 'bytes32',
name: 'name',
type: 'bytes32',
},
{
indexed: true,
internalType: 'address',
name: 'owner',
type: 'address',
},
{
indexed: false,
internalType: 'uint256',
name: 'created',
type: 'uint256',
},
{
indexed: false,
internalType: 'uint256',
name: 'deleted',
type: 'uint256',
},
],
name: 'Register',
type: 'event',
},
{
inputs: [],
name: '_owner',
outputs: [
{
internalType: 'address payable',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'bytes32',
name: '_bytes32',
type: 'bytes32',
},
],
name: 'bytes32ToString',
outputs: [
{
internalType: 'string',
name: '',
type: 'string',
},
],
stateMutability: 'pure',
type: 'function',
},
{
inputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
name: 'data',
outputs: [
{
internalType: 'enum Example.List',
name: 'list',
type: 'uint8',
},
{
internalType: 'bytes32',
name: 'name',
type: 'bytes32',
},
{
internalType: 'address',
name: 'owner',
type: 'address',
},
{
internalType: 'uint256',
name: 'created_at',
type: 'uint256',
},
{
internalType: 'uint256',
name: 'deleted_at',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [],
name: 'data_id',
outputs: [
{
internalType: 'uint256',
name: '',
type: 'uint256',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'enum Example.List',
name: '_list',
type: 'uint8',
},
{
internalType: 'bytes32',
name: '_name',
type: 'bytes32',
},
],
name: 'getFullName',
outputs: [
{
internalType: 'address',
name: '',
type: 'address',
},
],
stateMutability: 'view',
type: 'function',
},
{
inputs: [
{
internalType: 'enum Example.List',
name: '_list',
type: 'uint8',
},
{
internalType: 'bytes32',
name: '_name',
type: 'bytes32',
},
],
name: 'register',
outputs: [
{
internalType: 'bool',
name: 'success',
type: 'bool',
},
],
stateMutability: 'payable',
type: 'function',
},
]
Contract: https://testnet.snowtrace.io/address/0xf28c3e812cfe316ca099978c8e4cb53d81b41acf
Remix: