-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2952040
commit 3420520
Showing
25 changed files
with
243 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
{ | ||
"name": "zksync2-js-examples", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/chai": "^4.3.9", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.5.2", | ||
"c8": "^8.0.1", | ||
"chai": "^4.3.10", | ||
"ethers": "^6.7.1", | ||
"mocha": "^10.2.0", | ||
"prettier": "3.0.3", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.1.6" | ||
}, | ||
"peerDependencies": { | ||
"ethers": "^6.9.0" | ||
}, | ||
"dependencies": { | ||
"zksync-ethers": "^6.0.0" | ||
}, | ||
"scripts": { | ||
"test:prepare": "cd tests/setup/ && ./setup.sh && cd ../..", | ||
"test:wait": "ts-node tests/wait.ts", | ||
"test": "mocha -r ts-node/register tests/*.test.ts", | ||
"lint": "prettier . --write", | ||
"lint:check": "prettier . --check", | ||
"watch": "tsc --watch" | ||
} | ||
} | ||
"name": "zksync2-js-examples", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"@types/chai": "^4.3.9", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^20.5.2", | ||
"c8": "^8.0.1", | ||
"chai": "^4.3.10", | ||
"ethers": "^6.7.1", | ||
"mocha": "^10.2.0", | ||
"prettier": "3.0.3", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.1.6" | ||
}, | ||
"peerDependencies": { | ||
"ethers": "^6.9.0" | ||
}, | ||
"dependencies": { | ||
"zksync-ethers": "^6.0.0" | ||
}, | ||
"scripts": { | ||
"test:prepare": "cd tests/setup/ && ./setup.sh && cd ../..", | ||
"test:wait": "ts-node tests/wait.ts", | ||
"test": "mocha -r ts-node/register tests/*.test.ts", | ||
"lint": "prettier . --write", | ||
"lint:check": "prettier . --check", | ||
"watch": "tsc --watch" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
import {Provider, types, Wallet} from "zksync-ethers"; | ||
import {ethers} from "ethers"; | ||
import { Provider, types, Wallet } from "zksync-ethers"; | ||
import { ethers } from "ethers"; | ||
|
||
const provider = Provider.getDefaultProvider(types.Network.Sepolia); | ||
const ethProvider = ethers.getDefaultProvider("sepolia"); | ||
const PRIVATE_KEY = process.env.PRIVATE_KEY; | ||
const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider); | ||
|
||
|
||
async function main() { | ||
const token = "0x6a4Fb925583F7D4dF82de62d98107468aE846FD1"; | ||
const receiver = "0x81E9D85b65E9CC8618D85A1110e4b1DF63fA30d9"; | ||
|
||
console.log(`Account1 balance before transfer: ${await wallet.getBalance(token)}`); | ||
console.log(`Account2 balance before transfer: ${await provider.getBalance(receiver, 'latest', token)}`); | ||
console.log( | ||
`Account2 balance before transfer: ${await provider.getBalance(receiver, "latest", token)}`, | ||
); | ||
|
||
const tx = await wallet.transfer({ | ||
token: token, | ||
to: receiver, | ||
amount: 5, | ||
}); | ||
const receipt = await tx.wait(); | ||
const receipt = await tx.wait(); | ||
console.log(`Tx: ${receipt.hash}`); | ||
|
||
console.log(`Account1 balance after transfer: ${await wallet.getBalance(token)}`); | ||
console.log(`Account2 balance after transfer: ${await provider.getBalance(receiver, 'latest', token)}`); | ||
console.log( | ||
`Account2 balance after transfer: ${await provider.getBalance(receiver, "latest", token)}`, | ||
); | ||
} | ||
|
||
main().then().catch(error => { | ||
console.log(`Error: ${error}`); | ||
}) | ||
main() | ||
.then() | ||
.catch((error) => { | ||
console.log(`Error: ${error}`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.