ao-deploy
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

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 the process to spawn (default: "default")
  -w, --wallet [wallet]        Wallet JWK file path
  -s, --scheduler [scheduler]  Scheduler to use for Process (default: "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA")
  -m, --module [module]        The module source to use to spin up Process
  -c, --cron [interval]        Cron interval to use for Process i.e (1-minute, 5-minutes)
  -t, --tags [tags...]         Additional tags to use when spawning Process
  --retry-count [count]        Retry count to spawn Process (default: "10")
  --retry-delay [delay]        Retry delay in milliseconds (default: "3000")
  -h, --help                   display help for command

CLI Example

ao-deploy process.lua -n tictactoe -w wallet.json --tags name1:value1 name2:value2

OR,

aod process.lua -n tictactoe -w wallet.json --tags name1:value1 name2:value2

[!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

To deploy a contract, you need to import and call the deployContract function from your script. Here is a basic example:

Example

import { deployContract } from 'ao-deploy'

async function main() {
  try {
    const { messageId, processId } = await deployContract(
      {
        name: 'demo',
        wallet: 'wallet.json',
        contractPath: 'process.lua',
        tags: [{ name: 'Custom', value: 'Tag' }],
        retry: {
          count: 10,
          delay: 3000,
        },
      },
    )
    const processUrl = `https://ao_marton.g8way.io/#/process/${processId}`
    const messageUrl = `${processUrl}/${messageId}`
    console.log(`\nDeployed Process: ${processUrl} \nDeployment Message: ${messageUrl}`)
  }
  catch (error: any) {
    console.log('\nDeployment failed!\n')
    console.log(error?.message ?? 'Failed to deploy contract!')
  }
}

main()

Parameters

The deployContract function accepts the following parameters within the DeployArgs object:

  • name (optional): The process name to spawn. Defaults to "default".
  • contractPath: The path to the contract's main file.
  • module (optional): The module source to use. Defaults to fetching from the AOS's GitHub repository.
  • scheduler (optional): The scheduler to use for the process. Defaults to _GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA.
  • tags (optional): Additional tags to use for spawning the process.
  • cron (optional): The cron interval for the process, e.g., "1-minute", "5-minutes". Use format interval-(second, seconds, minute, minutes, hour, hours, day, days, month, months, year, years, block, blocks, Second, Seconds, Minute, Minutes, Hour, Hours, Day, Days, Month, Months, Year, Years, Block, Blocks)
  • wallet (optional): The wallet path or JWK itself (Autogenerated if not passed).
  • retry (optional): Retry options with count and delay properties. By default, it will retry up to 10 times with a 3000 milliseconds delay between attempts.

Author

👤 Pawan Paudel

🤝 Contributing

Contributions, issues and feature requests are welcome! \ Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

Copyright © 2024 Pawan Paudel.

Readme

Keywords

none

Package Sidebar

Install

npm i ao-deploy

Weekly Downloads

26

Version

0.1.4

License

MIT

Unpacked Size

44.9 kB

Total Files

9

Last publish

Collaborators

  • pawanpaudel93