-
Notifications
You must be signed in to change notification settings - Fork 0
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
0 parents
commit 90bf3ec
Showing
7 changed files
with
1,432 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
wallet.json |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { getDefaultProvider } = require("ethers"); | ||
const { Wallet, Provider } = require("zksync-web3"); | ||
|
||
// Lib | ||
const { getWallet } = require("./get-wallet"); | ||
|
||
// Config | ||
const token = "0x6842745bCDBa872C64CeE14C5036EF7AECD587ab"; | ||
|
||
// Get wallet and contract | ||
const zkSyncProvider = new Provider("https://zksync2-testnet.zksync.dev"); | ||
const ethereumProvider = getDefaultProvider("goerli"); | ||
const wallet = new Wallet( | ||
getWallet().privateKey, | ||
zkSyncProvider, | ||
ethereumProvider | ||
); | ||
|
||
// Deposit tokens | ||
(async () => { | ||
const tx = await wallet.addToken({ token }); | ||
console.log(await tx.wait()); | ||
})(); |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const { writeFileSync, existsSync } = require("fs"); | ||
const { Wallet } = require("ethers"); | ||
|
||
if (existsSync("wallet.json")) { | ||
console.log("Wallet already exists"); | ||
process.exit(-1); | ||
} | ||
|
||
const wallet = Wallet.createRandom(); | ||
writeFileSync("wallet.json", JSON.stringify(wallet.mnemonic)); |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const { getDefaultProvider } = require("ethers"); | ||
const { Wallet, Provider } = require("zksync-web3"); | ||
|
||
// Lib | ||
const { getWallet } = require("./get-wallet"); | ||
|
||
// Config | ||
const token = "0x6842745bCDBa872C64CeE14C5036EF7AECD587ab"; | ||
|
||
// Get wallet and contract | ||
const zkSyncProvider = new Provider("https://zksync2-testnet.zksync.dev"); | ||
const ethereumProvider = getDefaultProvider("goerli"); | ||
const wallet = new Wallet( | ||
getWallet().privateKey, | ||
zkSyncProvider, | ||
ethereumProvider | ||
); | ||
|
||
// Deposit tokens | ||
(async () => { | ||
const tx = await wallet.deposit({ | ||
token, | ||
amount: 100n * 10n ** 18n, | ||
approveERC20: true, | ||
}); | ||
console.log(await tx.wait()); | ||
})(); |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
const { readFileSync } = require("fs"); | ||
const { Wallet } = require("ethers"); | ||
|
||
const getWallet = () => { | ||
const json = JSON.parse(readFileSync("wallet.json")); | ||
return Wallet.fromMnemonic(json.phrase, json.path, json.locale); | ||
}; | ||
|
||
module.exports = { | ||
getWallet, | ||
}; | ||
|
||
if (require.main === module) { | ||
const wallet = getWallet(); | ||
console.log("Address:", wallet.address); | ||
console.log("Private key:", wallet.privateKey); | ||
} |
Oops, something went wrong.