Giter Club home page Giter Club logo

axelar-examples's Introduction

Axelar cross-chain dApp examples

Introduction

This repo provides the code for several example dApps in the Axelar Local Development Environment. Examples contain both JavaScript and Solidity smart contract code.

Note: Some example folders in this repo are not documented.

One-time setup

Install nodejs. Run node -v to check your installation.

Support Node.js version 16.x and 18.x

  1. Clone this repo:
git clone https://github.com/axelarnetwork/axelar-examples.git
  1. Navigate to axelar-examples and install dependencies:
npm install
  1. Compile smart contracts:
npm run build

Set environment variables

You can get started quickly with a random local key and .env file by running

npm run setup

Or you can manually copy the example .env.example file and fill in your EVM private key. See the example Metamask Instructions for exporting your private keys.

cp .env.example .env

Then update to your own private key.

Running the local chains

npm run start

Leave this node running on a separate terminal before deploying and testing the dApps.

Print wallet balances

This script will print your wallet balances for each chain.

npm run check-balance [local|testnet]

If not specified, this will print balances of the wallet for testnet.

Examples

axelar-examples's People

Contributors

annamarie2019 avatar benjamin852 avatar canhtrinh avatar eguajardo avatar ffe9f8 avatar foivos avatar ggutoski avatar ilyalukyanov avatar kalidax avatar milapsheth avatar npty avatar olanetsoft avatar raress96 avatar re1ro avatar sdaveas avatar stephenfluin avatar vladwulf avatar yongkangc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

axelar-examples's Issues

Cannot find module '@axelar-network/axelarjs-sdk'

 npm run send-token

> [email protected] send-token
> node src/send-token.js

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '@axelar-network/axelarjs-sdk'
Require stack:
- /Users/gus/Documents/axelar/git-repos/axelar-local-dev-sample/src/send-token.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/gus/Documents/axelar/git-repos/axelar-local-dev-sample/src/send-token.js:4:27)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/gus/Documents/axelar/git-repos/axelar-local-dev-sample/src/send-token.js'
  ]
}

Node.js v17.8.0

I thought the local-dev-sample no longer has a dependency on axelarjs-sdk.

Can't run hello world program

D:\BlockChainProjects\axelar-local-gmp-examples> node scripts/createLocal
D:\BlockChainProjects\axelar-local-gmp-examples\node_modules@ethersproject\bytes\lib\index.js:9
return !!(value.toHexString);
^

TypeError: Cannot read properties of undefined (reading 'toHexString')
at isHexable (D:\BlockChainProjects\axelar-local-gmp-examples\node_modules@ethersproject\bytes\lib\index.js:9:21)
at hexlify (D:\BlockChainProjects\axelar-local-gmp-examples\node_modules@ethersproject\bytes\lib\index.js:175:9)
at new SigningKey (D:\BlockChainProjects\axelar-local-gmp-examples\node_modules@ethersproject\signing-key\lib\index.js:20:82)
at new Wallet (D:\BlockChainProjects\axelar-local-gmp-examples\node_modules@ethersproject\wallet\lib\index.js:120:36)
at Object. (D:\BlockChainProjects\axelar-local-gmp-examples\scripts\createLocal.js:26:30)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)

Old testnet network config

Hi! I tried to use this repository, but as it turned out, the network configuration for the testnet is outdated. There is still rinkebay which is not used and manually changing the config to goerli does not work. Also, moonbeam should be called moonbase and change the rpc endpoint for it since this one does not work. Also, the website shows the new gateway contract addresses but the configuration is the same as before. Can you fix this?

improve usability and consistency of sendToMany `web-examples` UI

Change the name to indicate this is "send tokens to many addresses on another chain" example, with any references to custom logic being secondary.

Re-order the page to better match user expectations and our other examples (like sendToken):

  1. Start with the recipient address field
  2. "Add Random Address"
  3. Token Amount

users are unable to run `examples-web`

Examples:
https://discord.com/channels/770814806105128977/955655587260170272/1091860815570804806
https://discord.com/channels/770814806105128977/955655587260170272/1091870353707507713

Also getting

$ npm run deploy

> [email protected] deploy
> run-s contracts:build contracts:generate contracts:deploy


> [email protected] contracts:build
> hardhat compile

Error HH404: File @axelar-network/axelar-gmp-sdk-solidity/contracts/upgradable/BaseProxy.sol, imported from contracts/nft-linker/Proxy.sol, not found.

For more info go to https://hardhat.org/HH404 or run Hardhat with --show-stack-traces
ERROR: "contracts:build" exited with 1.

fix: `npm run deploy evm/nft-linker local` failed to execute

The command didn’t execute completely; it got stuck for some reason.

> [email protected] execute
> node scripts/runExecute evm/nft-linker local Avalanche Fantom

--- Initially ---
Token that was originally minted at Avalanche is at Avalanche.
Token that was originally minted at Fantom is at Fantom.


After retrying, it returned:

> [email protected] execute
> node scripts/runExecute evm/nft-linker local Avalanche Fantom

--- Initially ---
Token that was originally minted at Avalanche is at .
Token that was originally minted at Fantom is at Fantom.
/Users/mac/Desktop/GIT/axelar/axelar-examples/scripts/libs/utils.js:125
        CHAINS.TESTNET[source.name.toUpperCase()],
                              ^

TypeError: Cannot read properties of undefined (reading 'name')
    at calculateBridgeFee (/Users/mac/Desktop/GIT/axelar/axelar-examples/scripts/libs/utils.js:125:31)
    at Object.execute (/Users/mac/Desktop/GIT/axelar/axelar-examples/examples/evm/nft-linker/index.js:83:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async executeEVMExample (/Users/mac/Desktop/GIT/axelar/axelar-examples/scripts/libs/execute.js:65:5)

Node.js v18.13.0

Feedback from IMP-1

Since the #76 PR is quite big, I think it is more appropriate to address them later to make it easier to review.

@StephenFluin

I have some minor comments and more improvements for later, but this PR can be merged as is. Looks great!

why don't we have a shared sleep method? (we seem to redefine it in many places
why did you refactor to use arrow functions?
Some typos in untouched code I'll fix once this PR lands
(later) Looks like a bunch of format / whitespace changes, can you make sure the whitespace settings are in prettier in our global package.json (or appropriate prettier config file) so we all autoformat the same?

idea: symlink .env?

Right now developers have to run npm run setup to get examples-web to work.

Could we use a symlink instead from examples-web/.env -> ../.env ?

Thoughts @npty? This might break windows though, I'm not 100% sure.

reduce multiple chain-stack execution via configuration

Right now, most folks want our EVM examples, but everything is configured to run on every chain stack. This means that to use our simplest EVM example, you have to have python, and the system will run our Aptos code samples too.

To simplify, I propose we add a .env file configuration for chain stacks. Users can specify which chain stacks they want to build with (defaulting to EVM-only), which controls which chains will be executed/deployed/tested.

We could potentially add a prompt as well to help users choose and configure.

npm Install error on Windows 11

I'm encountering an error while trying to install the Axelar Example on my Windows machine. I have attempted to use bash to resolve the issue, but it still persists. I'm wondering if there's a way to run the required command on Windows 11.

npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c C:\Users\rambo\AppData\Local\Temp\postinstall-6c4eb99e.cmd
npm ERR! > @axelar-network/[email protected] build
npm ERR! > run-s build-aptos
npm ERR!
npm ERR!
npm ERR! > @axelar-network/[email protected] build-aptos
npm ERR! > ./aptos/build.sh
npm ERR! '.' is not recognized as an internal or external command,
npm ERR! operable program or batch file.
npm ERR! ERROR: "build-aptos" exited with 1.
npm ERR! ERROR: "build" exited with 1.

feat: remove hard dependencies on non-evm chain stacks

Right now when cloning and installing dependencies for this repo, we require all of the dependnecies of every chain stack we support (near, aptos, and more in the future).

This means that our repo is harder to install and maintain (windows support for example). We should design a new architecture that makes some of these optional dependencies, or not included at all, and then automatically add the additional dependencies based on the chain stacks a user wants to develop for.

waffle

Hello 👋
I'm setting up an axelar test environment and using this repo as orientation. However, when I try to run npm run build on my environment, it returns sh: 1: waffle: not found.

I have an identical package.json and waffle.json at root
image

I tried substituting waffle with ethereum-waffle and running rm -rf bulid && waffle waffle.json but to no avail.

Am I overlooking something? I'd appreciate any feedback.

checkBalances "could not detect network"

On a fresh install after running setup npm run build I try node scripts/checkBalances and get

node scripts/checkBalances.js
/Users/gus/Documents/axelar/git-repos/axelar-local-gmp-examples/node_modules/@ethersproject/logger/lib/index.js:233
        var error = new Error(message);
                    ^

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.8)
    at Logger.makeError (/Users/gus/Documents/axelar/git-repos/axelar-local-gmp-examples/node_modules/@ethersproject/logger/lib/index.js:233:21)
    at Logger.throwError (/Users/gus/Documents/axelar/git-repos/axelar-local-gmp-examples/node_modules/@ethersproject/logger/lib/index.js:242:20)
    at JsonRpcProvider.<anonymous> (/Users/gus/Documents/axelar/git-repos/axelar-local-gmp-examples/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:561:54)
    at step (/Users/gus/Documents/axelar/git-repos/axelar-local-gmp-examples/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
    at Object.throw (/Users/gus/Documents/axelar/git-repos/axelar-local-gmp-examples/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
    at rejected (/Users/gus/Documents/axelar/git-repos/axelar-local-gmp-examples/node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  reason: 'could not detect network',
  code: 'NETWORK_ERROR',
  event: 'noNetwork'
}

Node.js v17.8.0

[Fix]: 23 vulnerabilities (15 moderate, 5 high, 3 critical)

Running npm install returns vulnerabilities issues:

23 vulnerabilities (15 moderate, 5 high, 3 critical)

To address issues that do not require attention, run:
npm audit fix

To address all issues possible (including breaking changes), run:
npm audit fix --force

Allow cli options to specify starting chains

When running npm run start on our CLI, the default chains are launched. However, I would like to add options to allow users to specify which chains to launch at startup.

I propose adding options to specify the desired chains using a comma-separated list. For example:

npm run start --chains evm:avalanche,moonbeam --chains move:aptos,sui

This command would start the EVM chains on Avalanche and Moonbeam, and the Move chains on Aptos and SUI.

I believe that this feature would greatly enhance the flexibility and customization options to running our examples, and would be a valuable addition for our users.

Here's an example script to parse the example command above:

const { program } = require("commander");

function collect(value, previous) {
  return previous.concat([value]);
}

program
  .option(
    "--chains <chains>",
    "comma-separated list of chains to start",
    collect,
    []
  )
  .parse();

const options = program.opts();

const chains = options.chains.reduce((acc, chain) => {
  const [protocol, names] = chain.split(":");
  const chainNames = names.split(",");
  return {
    ...acc,
    [protocol]: chainNames,
  };
}, {});

console.log(chains);

Output

{ evm: [ 'avalanche', 'moonbeam' ], move: [ 'aptos', 'sui' ] }

all tests breaking

➜  axelar-local-gmp-examples git:(main) ✗ npm test

> [email protected] test
> hardhat test

An unexpected error occurred:

Error: Cannot find module '../artifacts/@axelar-network/axelar-cgp-solidity/contracts/TokenDeployer.sol/TokenDeployer.json'
Require stack:
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/@axelar-network/axelar-local-dev/dist/Network.js
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/@axelar-network/axelar-local-dev/dist/relay.js
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/@axelar-network/axelar-local-dev/dist/exportUtils.js
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/@axelar-network/axelar-local-dev/dist/index.js
- /home/ubuntu/ron/axelar-local-gmp-examples/scripts/createLocal.js
- /home/ubuntu/ron/axelar-local-gmp-examples/test/test.js
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/mocha/lib/mocha.js
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/mocha/index.js
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/hardhat/builtin-tasks/test.js
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/hardhat/internal/core/tasks/builtin-tasks.js
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/hardhat/internal/core/config/config-loading.js
- /home/ubuntu/ron/axelar-local-gmp-examples/node_modules/hardhat/internal/cli/cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/ubuntu/ron/axelar-local-gmp-examples/node_modules/@axelar-network/axelar-local-dev/src/Network.ts:9:23)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/ubuntu/ron/axelar-local-gmp-examples/node_modules/@axelar-network/axelar-local-dev/dist/Network.js',

seems axelar-local-gmp-examples still depends on these deprecated versions

https://github.com/axelarnetwork/axelar-local-gmp-examples/blob/a242d950dbb76e7471b16efd4b5055035f1f49c1/package-lock.json#L39-L66

hope we can:

  • publish npm packages with abi directly instead of the current git link as dependency
  • bump dependency to latest and update example contracts accordingly(construct breaking change)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.