offchainlabs / arbitrum-sdk Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://arbitrum-sdk.vercel.app
License: Apache License 2.0
Home Page: https://arbitrum-sdk.vercel.app
License: Apache License 2.0
On my ubuntu machine, I startup a local enviroment.
I used yarn gen:network
to generate localNetwork.json, whick reported:
Error: No such container: nitro_sequencer_1
Error: Command failed: docker exec nitro_sequencer_1 cat /config/deployment.json
Error: No such container: nitro_sequencer_1
at checkExecSyncError (node:child_process:841:11)
at execSync (node:child_process:912:15)
at getCustomNetworks (/root/arbitrum-sdk/scripts/testSetup.ts:65:34)
at setupNetworks (/root/arbitrum-sdk/scripts/testSetup.ts:131:74)
at main (/root/arbitrum-sdk/scripts/genNetwork.ts:12:55)
at Object.<anonymous> (/root/arbitrum-sdk/scripts/genNetwork.ts:26:1)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Module.m._compile (/root/arbitrum-sdk/node_modules/ts-node/src/index.ts:1597:23)
at Module._extensions..js (node:internal/modules/cjs/loader:1180:10) {
status: 1,
signal: null,
output: [
null,
<Buffer >,
<Buffer 45 72 72 6f 72 3a 20 4e 6f 20 73 75 63 68 20 63 6f 6e 74 61 69 6e 65 72 3a 20 6e 69 74 72 6f 5f 73 65 71 75 65 6e 63 65 72 5f 31 0a>
],
pid: 41792,
stdout: <Buffer >,
stderr: <Buffer 45 72 72 6f 72 3a 20 4e 6f 20 73 75 63 68 20 63 6f 6e 74 61 69 6e 65 72 3a 20 6e 69 74 72 6f 5f 73 65 71 75 65 6e 63 65 72 5f 31 0a>
}
Done in 10.15s.
It looks like the nitro_sequencer_1
is called nitro-sequencer-1
on ubuntu.
In your Readme file you mentioned that for bridgeStandardToken command:
Required CL params: networkID:number โ Chain ID of L1 network l1TokenAddress:string โ address of L1 token to be bridged
But actually, the networkID should be L2 network id.
Is there a way to deploy ArbSys
and ArbRetryableTx
at the same addresses that are used in production while using Ganache?
ArbSys
address: 0x0000000000000000000000000000000000000064
ArbRetryableTx
address: 0x000000000000000000000000000000000000006E
More generally, if you can point to some test or deployment script in this repo or the Arbitrum monorepo, that would be helpful.
A general pattern I think all rollups should land on as we move to a multi rollup world is the ability to get the rollup config on chain. This way you can bootstrap the arbitrum sdk with only the rpc url even if the rollup config hasn't been added to this sdk yet.
e.g.
const l2Network = await getL2NetworkFromRpc(
l2RpcUrl /** <-- rpc url of target Arbitrum chain */
)
This allows us to more easily make tooling work for all chains without needing to specify the config within the library first or needing to tediously craft your own config
yarn run v1.22.19
$ ts-node ./scripts/genNetwork.ts
123
Error: call revert exception [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="confirmPeriodBlocks()", data="0x", errorArgs=null, errorName=null, errorSignature=null, reason=null, code=CALL_EXCEPTION, version=abi/5.6.3)
at Logger.makeError (/home/test/arbitrum-tutorials/arbitrum-sdk/node_modules/@ethersproject/logger/src.ts/index.ts:261:28)
at Logger.throwError (/home/test/arbitrum-tutorials/arbitrum-sdk/node_modules/@ethersproject/logger/src.ts/index.ts:273:20)
at Interface.decodeFunctionResult (/home/test/arbitrum-tutorials/arbitrum-sdk/node_modules/@ethersproject/abi/src.ts/interface.ts:427:23)
at Contract.<anonymous> (/home/test/arbitrum-tutorials/arbitrum-sdk/node_modules/@ethersproject/contracts/src.ts/index.ts:400:44)
at step (/home/test/arbitrum-tutorials/arbitrum-sdk/node_modules/@ethersproject/contracts/lib/index.js:48:23)
at Object.next (/home/test/arbitrum-tutorials/arbitrum-sdk/node_modules/@ethersproject/contracts/lib/index.js:29:53)
at fulfilled (/home/test/arbitrum-tutorials/arbitrum-sdk/node_modules/@ethersproject/contracts/lib/index.js:20:58)
at processTicksAndRejections (internal/process/task_queues.js:95:5) {
reason: null,
code: 'CALL_EXCEPTION',
method: 'confirmPeriodBlocks()',
data: '0x',
errorArgs: null,
errorName: null,
errorSignature: null,
address: '0x91c9ca402976984c99ebd2b43826123442c592b8',
args: [],
transaction: {
data: '0x2e7acfa6',
to: '0x91c9Ca402976984C99eBD2B43826123442c592B8'
}
}
Done in 23.25s.
Rinkeby has been deprecated and integration tests no longer pass because the RPC server does not respond.
Changes should land into the v4 branch. The branch should be kept in sync with main
.
Hello
Im trying to estimate gas for transaction using
https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/gas-estimation
It works fine when I estimate simple transaction like sending ETH between 2 addresses without any additional data.
But when I pass the smart contract data like this:
0x1114cd2a000000000000000000000000000000000000000000000000000000000000006f000000000000000000000000409d44c6998bbdaa982f14b1cf2f12958b70abd800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000003b9ac9ff000000000000000000000000000000000000000000000000000000003b02337f0000000000000000000000000000000000000000000000000000000000000014409d44c6998bbdaa982f14b1cf2f12958b70abd8000000000000000000000000
Script always return an error.
Error: call revert exception; VM Exception while processing transaction: reverted with reason string "Stargate: msg.value must be > _amountLD" [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (method="gasEstimateComponents(address,bool,bytes)", data="0x08c379a00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000002753746172676174653a206d73672e76616c7565206d757374206265203e205f616d6f756e744c4400000000000000000000000000000000000000000000000000", errorArgs=["Stargate: msg.value must be > _amountLD"], errorName="Error", errorSignature="Error(string)", reason="Stargate: msg.value must be > _amountLD", code=CALL_EXCEPTION, version=abi/5.7.0)
at Logger.makeError (C:\Users\97158\Documents\GitHub\layerZero\node_modules@ethersproject\logger\src.ts\index.ts:269:28)
at Logger.throwError (C:\Users\97158\Documents\GitHub\layerZero\node_modules@ethersproject\logger\src.ts\index.ts:281:20)
errorSignature: 'Error(string)',
address: '0x00000000000000000000000000000000000000C8',
args: [
'0xbf22f0f184bccbea268df387a49ff5238dd23e40',
false,
'0x1114cd2a000000000000000000000000000000000000000000000000000000000000006f000000000000000000000000409d44c6998bbdaa982f14b1cf2f12958b70abd800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000003b9ac9ff000000000000000000000000000000000000000000000000000000003b02337f0000000000000000000000000000000000000000000000000000000000000014409d44c6998bbdaa982f14b1cf2f12958b70abd8000000000000000000000000'
],
transaction: {
data: '0xc94e6eeb000000000000000000000000bf22f0f184bccbea268df387a49ff5238dd23e400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e41114cd2a000000000000000000000000000000000000000000000000000000000000006f000000000000000000000000409d44c6998bbdaa982f14b1cf2f12958b70abd800000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000003b9ac9ff000000000000000000000000000000000000000000000000000000003b02337f0000000000000000000000000000000000000000000000000000000000000014409d44c6998bbdaa982f14b1cf2f12958b70abd800000000000000000000000000000000000000000000000000000000000000000000000000000000',
to: '0x00000000000000000000000000000000000000C8'
And this error looks like nodeInterface.callStatic.gasEstimateComponents
trying to execute transaction instead of estimate it.
transaction details.
0xbf22f0f184bccbea268df387a49ff5238dd23e40 - smart contract
swapETH - method
contract.methods
.swapETH(
destinationChainId, //111
request.senderAccount.address, //my address
request.senderAccount.address, //my address
request.amount, //0.04 eth (in wei)
minAmount //0.04 eth * 0.99 (in wei)
)
.encodeABI();
const baseL2Provider = new providers.StaticJsonRpcProvider(
"https://arb1.arbitrum.io/rpc"
);
addDefaultLocalNetwork();
const destinationAddress =contractAddress;
const nodeInterface = NodeInterface__factory.connect(
NODE_INTERFACE_ADDRESS,
baseL2Provider
);
//THROWING HERE
const gasEstimateComponents =
await nodeInterface.callStatic.gasEstimateComponents(
destinationAddress,
false,
data,
{
blockTag: "latest",
}
);
const l1GasEstimated = gasEstimateComponents.gasEstimateForL1;
const l2GasUsed = gasEstimateComponents.gasEstimate.sub(
gasEstimateComponents.gasEstimateForL1
);
const l2EstimatedPrice = gasEstimateComponents.baseFee;
const l1EstimatedPrice = gasEstimateComponents.l1BaseFeeEstimate.mul(16);
const l1Cost = l1GasEstimated.mul(l2EstimatedPrice);
const l1Size = l1Cost.div(l1EstimatedPrice);
const P = l2EstimatedPrice;
const L2G = l2GasUsed;
const L1P = l1EstimatedPrice;
const L1S = l1Size;
// L1C (L1 Cost) = L1P * L1S
const L1C = L1P.mul(L1S);
// B (Extra Buffer) = L1C / P
const B = L1C.div(P);
// G (Gas Limit) = L2G + B
const G = L2G.add(B);
// TXFEES (Transaction fees) = P * G
const TXFEES = P.mul(G);
return {
fullGas: G.toNumber(),
transactionFee: TXFEES.toNumber(),
};
maybe add some special deprecation order for the rinkarby chainid
here we can start at the L1 block number of the L2 genesis block instead of zero (might be nice to add this field to the networks object in arbitrum-sdk in fact ๐ค )
Originally posted by @DZGoldman in OffchainLabs/arbitrum-token-lists#45 (comment)
Right now you're only able to query by destination
, but we need to be able to query by the sender, too:
https://github.com/OffchainLabs/arbitrum-sdk/blob/main/src/lib/message/L2ToL1Message.ts#L106
These are currently run as part of the same job, but this integration tests are slow and require eternal deps, unit tests do not. We should separate them so it's easy to quickly run unit tests
To perform a withdrawal claim transaction, the following two lines are used to obtain the transaction hash:
const messageWriter = L2ToL1Message.fromEvent(l1Signer, event)
const res = await messageWriter.execute(l2.provider)
// res.hash will be the transaction hash used for tx submission later on
With l1Signer
, L2ToL1MessageWriter
is created.
arbitrum-sdk/src/lib/message/L2ToL1Message.ts
Lines 66 to 77 in bb398d4
arbitrum-sdk/src/lib/message/L2ToL1Message.ts
Lines 261 to 277 in bb398d4
Since L2ToL1MessageWriter
extends L2ToL1MessageReader
, let's look at L2ToL1MessageReader
.
Here, we can see that l1Signer.provider
is assigned to l1Provider
in the class in the constructor.
arbitrum-sdk/src/lib/message/L2ToL1Message.ts
Lines 184 to 191 in bb398d4
The issue we encountered concerned only L2ToL1MessageWriterNitro
and now we are in the nitro era, so let's look at L2ToL1MessageWriterNitro
.
It calls a method getOutboxProof
using the l2Provider
passed in, which seems to cover all we need.
arbitrum-sdk/src/lib/message/L2ToL1MessageNitro.ts
Lines 417 to 427 in bb398d4
In getOutboxProof
, it calls getSendProps
with the l2Provider.
arbitrum-sdk/src/lib/message/L2ToL1MessageNitro.ts
Lines 118 to 119 in bb398d4
Here we can see this.l1Provider
which is the provider from the l1Signer
object used.
If the provider is missing some essential properties for the node to call the contract method statically, our transaction would fail, which was what we experienced.
arbitrum-sdk/src/lib/message/L2ToL1MessageNitro.ts
Lines 239 to 248 in bb398d4
Revisit this PR and add tests.
full guide: https://viem.sh/docs/ethers-migration.html
Vercel is disabling v16 on 6 Feb 2024
As our UI repos using the SDK will need to be moved to node v18, we must ensure the SDK works on node v18 by then
https://vercel.com/changelog/node-js-14-and-16-are-being-deprecated
Rename L1 to "parent chain" and L2 to "chain".
getL1ERC20Address throws an error for WETH as the L2 WETH contract doesn't have the l1Address() function on it
We start a nitro nodes for the integration tests, we're currently using v2.0.0 in the tests but we should update this to a more recent version
arbitrum-sdk/scripts/deployStandard.ts
Line 122 in 3214774
I startup a local enviroment on ubuntu
, which the l1ChainId is 412346.
and deposit Eth by arbitrum-tutorial
, and it returns the following error:
root@iZj6cf3sxrlbuuiwe8tsonZ:~/arbitrum-tutorials/packages/eth-deposit# yarn run depositETH
yarn run v1.22.19
$ hardhat run scripts/exec.js
Environmental variables properly set ๐
๐ต๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต๐ต๐ต๐ต๐ต๐ต๐ต๐ต๐ต๐ต๐ต๐ต๐ต๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
๐ต ๐ต
Arbitrum Demo: Deposit Eth via Arbitrum SDK
Lets
Go โก๏ธ
...๐
ArbSdkError: Unrecognized network 412346.
at getNetwork (/root/arbitrum-tutorials/node_modules/@arbitrum/sdk-nitro/dist/lib/dataEntities/networks.js:223:15)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at isNitroL2 (/root/arbitrum-tutorials/node_modules/@arbitrum/sdk/dist/lib/utils/migration_types.js:192:23)
at getL2Network (/root/arbitrum-tutorials/node_modules/@arbitrum/sdk/dist/lib/dataEntities/networks.js:64:9)
at main (/root/arbitrum-tutorials/packages/eth-deposit/scripts/exec.js:36:21) {
inner: undefined
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Currently, in order to use the Arbitrum SDK in your project, you have to use ethers@v5
, as a lot (if not all) SDK methods accept and receive ethers@v5
objects, like Signer
, Provider
, TransactionReceipt
etc.
Ideally, we should be able to support using any of them, e.g. ethers@v5
, ethers@v6
, viem
, web3.js
etc, while continuing to use ethers
for our implementation. Maybe we could reduce the dependencies to the minimum interfaces needed, and then write small adapters that map objects from different libraries to the shared interfaces? It would be cool if the user could just "pick" an adapter once when configuring the library without having to do it at every call site.
As a PoC, we could try doing so for a couple of read and write methods:
This is a huge breaking change so probably targets v4, but worth exploring.
Currently it's only possible to deposit to yourself but we could use retryable tickets to deposit to a different address.
The annoying thing about this is that it would mean deposits to a different address use the retryable ticket flow, and so a different type system
calling estimateAll
on an instance of L1ToL2MessageGasEstimator
throws an error ArbSdkError: Unrecognized network 421612
.
Looked into the source files to notice that the network config for nitro is missing.
Is there an easy workaround for this?
tried package v2.0.0 and v3.0.0-beta2
In most flow, we call isNitroL1
or isNitroL2
in the migration sdk to detect if the network is nitro, if so we call generateL2NitroNetwork to update the contract addresses from the delayed inbox.
arbitrum-sdk/src/lib/utils/migration_types.ts
Lines 180 to 183 in 1a66fc9
However in L2ToL1Message
constructor we never call isNitroL1
or isNitroL2
and hence the network is not generated
arbitrum-sdk/src/lib/message/L2ToL1Message.ts
Lines 192 to 194 in 1a66fc9
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.