To install `@instadapp/avocado`, execute one of the following commands in your terminal:
```bash
# npm
npm install @instadapp/avocado
# yarn
yarn add @instadapp/avocado
# pnpm
pnpm install @instadapp/avocado
```
## Connection via MetaMask
Requirements:
- Users must be connected to the Avocado Network to sign transaction data messages.
-`ethersjs` is preferred over `web3js` for compatibility reasons.
## Retrieve Avocado Safe Address
```javascript
import { createSafe } from '@instadapp/avocado'
// Should be connected to chainId 634 (https://rpc.avocado.instadapp.io), before doing any transaction
const provider = new ethers.providers.Web3Provider(window.ethereum, "any")
const safe = createSafe(provider.getSigner())
// Getting User's AvoSafe address
const safeOwner = await safe.getOwnerAddress()
```
## Send Transaction to Avocado:
```javascript
import { createSafe } from '@instadapp/avocado'
// Should be connected to chainId 634 (https://rpc.avocado.instadapp.io), before doing any transaction
const provider = new ethers.providers.Web3Provider(window.ethereum, "any")
const safe = createSafe( provider.getSigner() )
// Sending 0.1 ETH to Vitalk
cosnt tx = await safe.sendTransaction({
to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
value: 1e18,
chainId: 1
})
```
Note: The underlying `chainId` can be included with the transaction data.
## Send Transaction to Avocado (Reveune Sharing Program):
```javascript
import { createSafe } from '@instadapp/avocado'
// Should be connected to chainId 634 (https://rpc.avocado.instadapp.io), before doing any transaction
const provider = new ethers.providers.Web3Provider(window.ethereum, "any")
const safe = createSafe( provider.getSigner() )
const referralAddress = "0x_____" // Default: "0x000000000000000000000000000000000000Cad0" // If Source address is passed, then 10% of the transaction fee shared with referral address.
// Sending 0.1 ETH to Vitalk
cosnt tx = await safe.sendTransaction({
to: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
value: 1e18,
chainId: 1
}, { source: referralAddress })
```
Note: Currently, withdrawal for source/referral is not live yet.
## Top-up USDC Gas Balance:
```javascript
import { createSafe } from '@instadapp/avocado'
// Should be connected to chainId 634 (https://rpc.avocado.instadapp.io), before doing any transaction
const provider = new ethers.providers.Web3Provider(window.ethereum, "any")