Quick Start
This guide will walk you through the steps in setting up a new project, how to write your first script, and how to deploy your first project.
Prerequisites
Before starting, make sure you have the following installed:
- Node.js (opens in a new tab) >=22.0.0 installed
curl https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install 22
nvm alias default 22
nvm use default
- Foundry (opens in a new tab) binary installed
curl -L https://foundry.paradigm.xyz | bash
source /root/.bashrc
foundryup
- Bun (opens in a new tab) installed
curl -fsSL https://bun.sh/install | bash
source /root/.bashrc
npm
and npx
in the following steps. But it's recommended to use bun
for better speed and compatibility.Install
Create a new project folder.
mkdir my-first-project
cd my-first-project
Initialize a new Node.js project using the following command.
bun init -y
Install @infinit-xyz/cli
package.
bun add @infinit-xyz/cli
Initialize
To initialize a new INFINIT project, run the following command.
bunx infinit init
You will be prompt to input the following details
- Project Root Directory: Specify the root directory of your project. The default will be your current directory.
- Chain: Select the chain that you want to use for your project. Check the Configuration for more details.
- Protocol Module: Select the module that you want to use for your project. Check the Module for more details.
- Accounts: This option will be prompted if you have an existing account. You can select the account that you want to use as a deployer for your project.
After confirming all the details, the CLI will initialize the project and install the necessary dependencies. You will get the project with the following structure.
- infinit.config.yaml
- infinit.registry.json
- README.md
Create an account
To create a new account, run the following command.
bunx infinit account generate
You will be prompt to input the following details
- Account ID: A unique identifier for the account. It will be used to reference the account in the project.
- Password: A password to encrypt the private key. You will need this password to unlock the account.
Start building
Go to src/scripts
to start building your first script.
The script must:
- Import an action from the module to define its functionality.
- Define
params
andaccounts
objects for executing the action.
Learn more about Module and Action & Script.
Example
This example script is from the @infinit-xyz/uniswap-v3
module. The script for uses DeployUniswapV3Action
action to deploy the whole Uniswap V3 protocol smart contracts.
There're 2 main parts of the script file that you need to fill in:
params
: The parameters required for the action in the script. (Line 7-30)accounts
: The mapping of the required roles in the acount to the associated account id that you want to use to make the transaction. (Line 33-35) You can find the account id usingbunx infinit account list
command.
import { DeployUniswapV3Action, type actions } from '@infinit-xyz/uniswap-v3/actions'
import type { z } from 'zod'
type Param = z.infer<typeof actions['init']['paramSchema']>
// TODO: Replace with actual params
const params: Param = {
// TODO: Native currency label (e.g., ETH)
"nativeCurrencyLabel": undefined,
// TODO: Address of the owner of the proxy admin
"proxyAdminOwner": undefined,
// TODO: Address of the owner of factory
"factoryOwner": undefined,
// TODO: Address of the wrapped native token (e.g., '0x123...abc')
"wrappedNativeToken": undefined
}
// TODO: Replace with actual account id
const accounts = {
"deployer": ""
}
export default { params, signer: accounts, Action: DeployUniswapV3Action }
Example of the final script file for deploying Uniswap V3 protocol smart contract on Ethereum Chain.
import { DeployUniswapV3Action, type actions } from '@infinit-xyz/uniswap-v3/actions'
import type { z } from 'zod'
type Param = z.infer<typeof actions['init']['paramSchema']>
// TODO: Replace with actual params
const params: Param = {
// TODO: Native currency label (e.g., ETH)
"nativeCurrencyLabel": 'ETH',
// TODO: Address of the owner of the proxy admin
"proxyAdminOwner": '0xE04A57dFC52B65C1ABaDc8D9F7b968Ea60685b3E',
// TODO: Address of the owner of factory
"factoryOwner": '0xE04A57dFC52B65C1ABaDc8D9F7b968Ea60685b3E',
// TODO: Address of the wrapped native token (e.g., '0x123...abc')
"wrappedNativeToken": '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
}
// TODO: Replace with actual account id
const accounts = {
"deployer": "test-acc"
}
export default { params, signer: accounts, Action: DeployUniswapV3Action }
Execute the script
To execute the script, run the following command. Make sure that the account you specified in the script has enough balance on the target chain to execute the transaction. There's also an optional step in the command to estimate the gas fee for the transaction.
bunx infinit script execute deployUniswapV3Action.script.ts
After executing the script, all of the deployed contract addresses will be saved in the registry.infinit.json
file.
{
"uniswapV3Factory": "0x9a8b7c6d5e4f3210abcd0987ef654321fedcba98",
"nftDescriptor": "0x8b7c6d5e4f3210abcd0987ef654321fedcba9876",
"tickLens": "0x7c6d5e4f3210abcd0987ef654321fedcba987654",
"proxyAdmin": "0x6d5e4f3210abcd0987ef654321fedcba98765432",
"quoterV2": "0x5e4f3210abcd0987ef654321fedcba9876543210",
"nonfungibleTokenPositionDescriptorImpl": "0x4f3210abcd0987ef654321fedcba9876543210ab",
"nonfungibleTokenPositionDescriptor": "0x3e2d1c0b9a8f7654d3c2b1a0fedcba987654321f",
"nonfungiblePositionManager": "0x2d1c0b9a8f7654d3c2b1a0fedcba987654321fed",
"swapRouter02": "0x1c0b9a8f7654d3c2b1a0fedcba987654321fedcb"
}
That's it! 🔥
You have successfully deployed the Uniswap V3 protocol smart contracts on the Ethereum chain. Learn more about INFINIT in the Guides section.