Skip to content

An Arweave util to bundle multiple files in a single transaction and upload them to the Permaweb

License

Notifications You must be signed in to change notification settings

OutlierVentures/arweave-bundler

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Arweave Bundler

view on npm Licence

A library to simplify publishing single page web apps (SPAs) or other static content to the Permaweb aka Arweave.

It bundles your files together, so you can upload in one transaction, rather than uploading separate files using the using the ANS-104 standard.

It also maps individual file paths to their locations on Arweave via a manifest file so that your dApp works as if it was hosted on a S3 bucket.

Whether you prefer to use GitHub Actions or deploy directly through the CLI, arweave-hundler makes it easy.

The lib uses semantic versioning.

Requirements

  • An Arweave wallet
  • Some $AR (the simplest is to get a small amount through an exchange )

If you don't already have an Arweave wallet you can create one by running:

  pnpm install arweave
  node -e "require('arweave').init({}).wallets.generate().then(JSON.stringify).then(console.log.bind(console))" > wallet.json

GitHub Action

The action has multiple commands: upload, address, set. All commands require the private-key (base64 encoded) and the network to be passed. Optionally you can test the commands without broadcast a transaction by setting dry-run: true

upload

Specify the command upload and the directory to publish to the permaweb the entire directory as an ANS-104 bundle.

- name: upload the directory
  uses: outlierventures/[email protected]
  with:
    command: upload
    directory: build/
    private-key: ${{secrets.ARWEAVE_PRIVATE_KEY}}
    network: arweave.net

If an ant-address is provided the action will update the ArNS with the manifest-id of the bundle published. In order to use this feature is required to have an ArNS name. You can learn more here: https://ar.io/docs/arns/#overview and get an address here: https://arns.app/

- name: upload the directory
  uses: outlierventures/[email protected]
  with:
    command: upload
    directory: build/
    private-key: ${{secrets.ARWEAVE_PRIVATE_KEY}}
    ant-address: 'your-ant-address'
    network: arweave.net

set

Specify the command set to update an ant-address to a given manifest-id

- name: get the public address from the private key
  uses: outlierventures/[email protected]
  with:
    command: address
    private-key: ${{secrets.ARWEAVE_PRIVATE_KEY}}

address

Specify the command address to retrieve the public address from the private-key provided

- name: get the public address from the private key
  uses: outlierventures/[email protected]
  with:
    command: address
    private-key: ${{secrets.ARWEAVE_PRIVATE_KEY}}

Run the CLI

All the Github actions are available to the CLI as well

upload

npx @outlierventures/arweave-bundler@latest upload build/ --private-key ${PRIVATE_KEY}

alternatively you can upload and update the ant-address

 npx @outlierventures/arweave-bundler@latest upload build/ --ant-address your-ant-address --private-key ${PRIVATE_KEY}

set

 npx @outlierventures/arweave-bundler@latest set --ant-address your-ant-address --manifest-id your-manifest-id --private-key ${PRIVATE_KEY}

help

arweave-bundler <command>

Commands:
  arweave-bundler upload <directory>  Upload a directory to Arweave as bundle
  arweave-bundler address             Print the address of the wallet
  arweave-bundler set                 Set Arweave Name Token record to the manifest id

Options:
  --version  Show version number                                       [boolean]
  --help     Show help                                                 [boolean]

Developement requirement

  • Node v20 (LTS)
  • pnpm
  • npx
  • An Arweave private key with some $AR funds

Troubleshooting

  • Create a base64 encoded private key from a JSON file openssl base64 -in wallet.json -A -out base64key.txt
  • Export as string a privateKey
export PRIVATE_KEY=`cat base64key.txt`

Development

Test in local the CLI

rm -rf node_modules
pnpm i --prod
npx . address --private-key $PRIVATE_KEY

About

An Arweave util to bundle multiple files in a single transaction and upload them to the Permaweb

Resources

License

Stars

Watchers

Forks

Packages

No packages published