# Get from Contract

Fetch data from your deployed smart contract.

```ts title="Pure JS"
import { mega } from '@megaeth-labs/wallet-sdk';

const value = await mega.getFromContract<bigint>({
    address: '0x3e942744C21Eec1D88FBD463Fd0CcE42891Aec5C',
    abi: storageAbi,
    functionName: 'retrieve',
    args: [],
});
```

```tsx title="React"
import { useGetFromContract } from '@megaeth-labs/wallet-sdk-react';
import { useEffect } from 'react';

export default function StoredValue() {
    const { mutate: getFromContract, data } = useGetFromContract();

    useEffect(() => {
        getFromContract({
            address: '0x3e942744C21Eec1D88FBD463Fd0CcE42891Aec5C',
            abi: storageAbi,
            functionName: 'retrieve',
            args: [],
        });
    }, [getFromContract]);

    return <p>Stored value: {String(data ?? '…')}</p>;
}
```

```tsx title="Wagmi"
import { useReadContract } from 'wagmi';

export default function StoredValue() {
    const { data } = useReadContract({
        address: '0x3e942744C21Eec1D88FBD463Fd0CcE42891Aec5C',
        abi: storageAbi,
        functionName: 'retrieve',
    });

    return <p>Stored value: {String(data ?? '…')}</p>;
}
```

```ts
interface GetFromContractRequest {
    address: `0x${string}`;
    abi: any;
    functionName: string;
    args: any[];
}

// Resolves to the function's return value
```
