Skip to content

pawanpaudel93/ao-deploy

Repository files navigation

ao-deploy

npm version npm downloads bundle JSDocs License

A package to deploy AO contracts.

Installation

Using npm

npm install ao-deploy --save-dev

Using pnpm

pnpm add ao-deploy --save-dev

Using yarn

yarn add ao-deploy --dev

Using bun

bun add ao-deploy --dev

Usage

CLI

Usage: ao-deploy [options] <contractPath>

A CLI tool to deploy AO contracts

Arguments:
  contractPath                    Contract main file path to deploy

Options:
  -V, --version                   output the version number
  -n, --name [name]               Name of contract to deploy (default: "default")
  -w, --wallet-path [walletPath]  Wallet JWK file path
  -h, --help                      display help for command

Example

ao-deploy process.lua -n tictactoe -w wallet.json

OR,

aod process.lua -n tictactoe -w wallet.json

Note

A wallet is generated and saved if not passed.

Run this command to get the generated wallet path:

node -e "const path = require('path'); const os = require('os'); console.log(path.resolve(os.homedir(), '.aos.json'));"

Code

import { deployContract } from 'ao-deploy'

async function main() {
  try {
    const { messageId, processId } = await deployContract({ name: 'demo', walletPath: 'wallet.json', contractPath: 'process.lua' })
    const processUrl = `https://ao_marton.g8way.io/#/process/${processId}`
    console.log(`\nDeployed Process: ${processUrl} \nDeployment Message: ${processUrl}/${messageId}`)
  }
  catch (error: any) {
    console.log('\nDeploy failed!\n')
    console.log(error?.message ?? 'Failed to deploy contract!')
  }
}

main()

License

MIT License © 2024-PRESENT Pawan Paudel