question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failure: invalid address or ENS name (argument="name", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.5.0)

See original GitHub issue

Hello! It is my first time issuing anything on github 😃

Anyways, I had a problem using ethers with truffle and serverless (lambda).

`

const l1Provider = new providers.JsonRpcProvider(someTestNetRPC + infuraKey);
const l2Provider = new providers.JsonRpcProvider(someSideChainRPC + infuraKey);
console.log("Providers getting ready for deposit custom token...");

await l1Provider.ready; 
console.log("Layer 1 provider has been readied...");
await l2Provider.ready;
console.log("Layer 2 provider has been readied...");

console.log("Providers have been established... Waiting for Bridge initiation");

var requestData = event.queryStringParameters;

var tokenAmount = requestData["tokenAmount"];
// var secretMnemonic = requestData["mnemonic"];

console.log("Token Amount: " + BigNumber.from(tokenAmount));

const l1Wallet = new Wallet(secretKey, l1Provider);
const l2Wallet = new Wallet(secretKey, l2Provider);

const bridge = await Bridge.init(l1Wallet, l2Wallet);
console.log("Bridge Has been initiated!");

console.log("Target Token Address: " + tokenAddress);

const approveTx = await bridge.approveToken(tokenAddress);
const approveRec = await approveTx.wait();

console.log("Transaction Hash: " + approveRec.transactionHash + '\nCompleted Approving Contract. You will be seeing the result very soon');
console.log("Type of data type Contract Address: " + typeof(tokenAddress));

const depositTx = await bridge.deposit(
    tokenAddress, 
    BigNumber.from(tokenAmount), 
    // BigNumber.from(10000000000000), 
    // BigNumber.from(0), 
    // undefined,
    // {gasLimit: 210000, gasPrice: utils.parseUnits("10", "gwei")}
);

` Above is my code, I hope this is eligible. As you can see I am trying to deposit erc 20 token to my side chain, and I have used the example code to make transition happen. However, from ethers part, I keep on getting invalid address or ENS name. I am pretty sure that it takes my token Address as an undefined variable, which I checked it goes in as string. Also, I keep my tokenAddress, infura keys , and secret keys in .env file. (I hope it does not matter).

I am really sorry if this is not ethers’ problem, but I wasn’t sure if it is ethers’ part or the bridge’s part. It will be really helpful if anyone has any opinion on this one. Cheers

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
aspierscommented, Jan 23, 2022

@ricmoo commented on January 9, 2022 6:29 PM:

@purevolcano106 this usually means you are passing the wrong call value in. Try using console.log on the values you are passing in, something is undefined.

Unfortunately that’s just a very inefficient workaround. The real problem is that the stack trace doesn’t give the necessary information about the source of the issue. It would be great to fix this instead, then I suspect many of these issues would never be reported because it would be super easy to debug them.

0reactions
purevolcano106commented, Jan 10, 2022

This is test code.

const { providers, Wallet, BigNumber, utils } = require(‘ethers’) const { Provider, TransactionRequest } = require(‘@ethersproject/providers’) const { Contract, ContractFactory, Overrides } = require(‘@ethersproject/contracts’) const { Bridge, networks } = require(‘arb-ts’)

const L1TokenABI = require(“…/artifacts/contracts/L1Token.sol/L1Token.json”) const L2TokenABI = require(“…/artifacts/contracts/L2Token.sol/L2Token.json”)

const main = async () => {

const walletPrivateKey = process.env.DEVNET_PRIVKEY

const l1TokenAddress = "0xBDBA9215E597527ca9f538F55E4F8180C79f8b7c";
const l2TokenAddress = "0xE21E8Fd3CD87Dd058d9a894914322A7dfBAF0e4b";

const l1Provider = new providers.JsonRpcProvider(process.env.L1RPC)
const l2Provider = new providers.JsonRpcProvider(process.env.L2RPC)

const l1Wallet = new Wallet(walletPrivateKey, l1Provider)
const l2Wallet = new Wallet(walletPrivateKey, l2Provider)

const bridge = await Bridge.init(l1Wallet, l2Wallet)

const L1Factory = new Contract(l1TokenAddress, L1TokenABI.abi, l1Provider)
const L2Factory = new Contract(l2TokenAddress, L2TokenABI.abi, l2Provider)

const L1Token = await L1Factory.connect(l1Wallet)
const L2Token = await L2Factory.connect(l2Wallet)

const bal1 = await L1Token.balanceOf(l1Wallet.address)
console.log("L1 balance: " + bal1.toString());
const bal2 = await L2Token.balanceOf(l2Wallet.address)
console.log("L2 balance: " + bal2.toString());

// const approveRes = await L1Token.approve(l1TokenAddress, bal1)
// const approveRec = await approveRes.wait()
// console.log("approve status: ", approveRec.status);

const allowance = await L1Token.allowance(l1Wallet.address, l1TokenAddress)
console.log("allowance: " + allowance.toString());

// const depositRes = await L1Token.functions.deposit(l1TokenAddress, l2Wallet.address, bal1, BigNumber.from(0), BigNumber.from(10000000000000), BigNumber.from(0), '0x', { gasLimit: 210000, gasPrice: utils.parseUnits('10', 'gwei') })
// const depositRec = await depositRes.wait()
// console.log(depositRec.status)

/**
 * The Standard Gateway contract will ultimately be making the token transfer call; thus, that's the contract we need to approve.
 * bridge.approveToken handles this approval
 */
// const approveTx = await bridge.approveToken(l1TokenAddress)
// const approveRec = await approveTx.wait()
// console.log(
//   `You successfully allowed the Arbitrum Bridge to spend DappToken ${approveRec.transactionHash}`
// )

/**
 * Deposit DappToken to L2 using Bridge. This will escrows funds in the Gateway contract on L1, and send a message to mint tokens on L2.
 * The bridge.deposit method handles computing the necessary fees for automatic-execution of retryable tickets — maxSubmission cost & l2 gas price * gas — and will automatically forward the fees to L2 as callvalue
 * Also note that since this is the first DappToken deposit onto L2, a standard Arb ERC20 contract will automatically be deployed.
 */
console.log("deposit starts ...")
const depositTx = await bridge.deposit(l1TokenAddress, bal1)
console.log("deposit starts waiting ...")
const depositRec = await depositTx.wait()

/**
 * Now we track the status of our retryable ticket
 */
console.log("start to get inbox seqnum ... ")
//  First, we get our txn's sequence number from the event logs (using a handy utility method). This number uniquely identifies our L1 to L2 message (i.e., our token deposit)
const seqNumArr = await bridge.getInboxSeqNumFromContractTransaction(
  depositRec
)

/**
 * Note that a single txn could (in theory) trigger many l1-to-l2 messages; we know ours only triggered 1 tho.
 */
const seqNum = seqNumArr[0]
console.log(
  `Sequence number for your transaction found: ${seqNum.toNumber()}`
)

/**
 *  Now we can get compute the txn hashes of the transactions associated with our retryable ticket:
 * (Note that we don't necessarily need all of these (and will only use one of them ), but we include them all for completeness)
 */
// retryableTicket: quasi-transaction that can be redeemed, triggering some L2 message
const retryableTicket = await bridge.calculateL2TransactionHash(seqNum)
//  autoRedeem: record that "automatic" redemption successfully occurred
const autoRedeem = await bridge.calculateRetryableAutoRedeemTxnHash(seqNum)
// L2 message (in our case, mint new token)
const redeemTransaction = await bridge.calculateL2RetryableTransactionHash(
  seqNum
)

/** Now, we have to wait for the L2 tx to go through; i.e., for the Sequencer to include it in its off-chain queue. This should take ~10 minutes at most
 * If the redeem succeeds, that implies that the retryableTicket has been included, and autoRedeem succeeded as well
 */
console.log('waiting for L2 transaction:')
const l2TxnRec = await l2Provider.waitForTransaction(
  redeemTransaction,
  undefined,
  1000 * 60 * 12
)

console.log(
  `L2 transaction found! Your DappToken balance is updated! ${l2TxnRec.transactionHash}`
)

/**
 * Not that our txn has succeeded, we know that a token contract has been deployed on L2, and our tokens have been deposited onto it.
 * Let's confirm our new token balance on L2!
 */

const l2Data = await bridge.getAndUpdateL2TokenData(l1TokenAddress)
const l2WalletTokenBalance = l2Data && l2Data.ERC20 && l2Data.ERC20.balance
console.log(
  `your l2Wallet has ${l2WalletTokenBalance.toString()} DappToken now!`
)

}

main() .then(() => process.exit(0)) .catch(error => { console.error(error) process.exit(1) })

And this is the result of console.

L1 balance: 3000000000000000000 L2 balance: 0 allowance: 3000000000000000000 deposit starts … Error: invalid address or ENS name (argument=“name”, value=undefined, code=INVALID_ARGUMENT, version=contracts/5.5.0) at Logger.makeError (E:\My Work\Emax, John Murrish\arbitrum-bridge\node_modules@ethersproject\logger\src.ts\index.ts:225:28) at Logger.throwError (E:\My Work\Emax, John Murrish\arbitrum-bridge\node_modules@ethersproject\logger\src.ts\index.ts:237:20) at Logger.throwArgumentError (E:\My Work\Emax, John Murrish\arbitrum-bridge\node_modules@ethersproject\logger\src.ts\index.ts:241:21) at E:\My Work\Emax, John Murrish\arbitrum-bridge\node_modules@ethersproject\contracts\src.ts\index.ts:120:16 at step (E:\My Work\Emax, John Murrish\arbitrum-bridge\node_modules@ethersproject\contracts\lib\index.js:48:23) at Object.next (E:\My Work\Emax, John Murrish\arbitrum-bridge\node_modules@ethersproject\contracts\lib\index.js:29:53) at fulfilled (E:\My Work\Emax, John Murrish\arbitrum-bridge\node_modules@ethersproject\contracts\lib\index.js:20:58) at processTicksAndRejections (node:internal/process/task_queues:96:5) { reason: ‘invalid address or ENS name’, code: ‘INVALID_ARGUMENT’, argument: ‘name’, value: undefined }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: invalid address or ENS name (argument="name", value ...
Now I get this error Error: invalid address or ENS name (argument=“name”, value=2, code=INVALID_ARGUMENT, version=contracts/5.6.0) const ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found