generated from dgma/nodejs-web3-starter
-
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
1 parent
e52a252
commit 570a2b2
Showing
6 changed files
with
70 additions
and
61 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
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,73 +1,18 @@ | ||
version: "3.7" | ||
|
||
services: | ||
funding: | ||
mono: | ||
image: mono | ||
restart: always | ||
build: | ||
context: . | ||
command: ["make", "funding"] | ||
secrets: | ||
- master_key | ||
logging: &loggin | ||
driver: "json-file" | ||
options: | ||
max-file: "5" | ||
max-size: "100m" | ||
fuel: | ||
image: mono | ||
restart: always | ||
build: | ||
context: . | ||
command: ["make", "fuel"] | ||
logging: *loggin | ||
secrets: | ||
- master_key | ||
scroll-kelp: | ||
image: mono | ||
restart: always | ||
build: | ||
context: . | ||
command: ["make", "scroll-kelp"] | ||
logging: *loggin | ||
secrets: | ||
- master_key | ||
scroll-canvas: | ||
image: mono | ||
restart: always | ||
build: | ||
context: . | ||
command: ["make", "scroll-canvas"] | ||
logging: *loggin | ||
secrets: | ||
- master_key | ||
symbioticYT2: | ||
image: mono | ||
restart: always | ||
build: | ||
context: . | ||
command: ["make", "distributeERC"] | ||
logging: *loggin | ||
secrets: | ||
- master_key | ||
karakYT: | ||
image: mono | ||
restart: always | ||
build: | ||
context: . | ||
command: ["make", "distributeERC"] | ||
logging: *loggin | ||
secrets: | ||
- master_key | ||
fuelDust: | ||
image: mono | ||
restart: always | ||
build: | ||
context: . | ||
command: ["make", "distributeERC"] | ||
logging: *loggin | ||
secrets: | ||
- master_key | ||
secrets: | ||
master_key: | ||
file: ./master_key |
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,12 @@ | ||
import * as chains from "viem/chains"; | ||
import { distributeNative } from "src/core/distribution"; | ||
import { getAppConf } from "src/libs/configs"; | ||
import { logger } from "src/logger"; | ||
|
||
(async function main() { | ||
logger.info("initiated", { label: "CLI::distributeNative" }); | ||
const conf = await getAppConf(); | ||
const { chain } = conf.cli.distribute; | ||
await distributeNative(chains[chain]); | ||
logger.info("finished", { label: "CLI::distributeNative" }); | ||
})(); |
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { privateKeyToAccount } from "viem/accounts"; | ||
import { Chain } from "viem/chains"; | ||
import { getClient } from "src/libs/clients"; | ||
import { getEVMWallets } from "src/libs/configs"; | ||
// import { refreshProxy } from "src/libs/proxify"; | ||
import { sleep, getRandomArbitrary } from "src/libs/shared"; | ||
import { logger } from "src/logger"; | ||
|
||
export const distributeNative = async (chain: Chain) => { | ||
const wallets = await getEVMWallets(); | ||
|
||
const client = await getClient(chain); | ||
|
||
const value = await client.getBalance({ | ||
address: wallets[0].address, | ||
}); | ||
|
||
logger.debug(`balance of ${wallets[0].address} is ${value}`, { label: "core/distributeNative" }); | ||
|
||
let valueLeft = value; | ||
|
||
const config = wallets.slice(1).map(({ address }, index) => { | ||
const amount = (valueLeft / 100n) * BigInt(index + 1); | ||
valueLeft -= amount; | ||
return { | ||
to: address, | ||
amount, | ||
}; | ||
}); | ||
|
||
if (value - valueLeft !== config.reduce((acc, { amount }) => acc + amount, 0n)) { | ||
logger.error(`config creation error`, { | ||
label: "core/distributeNative", | ||
}); | ||
} | ||
|
||
for (const item of config) { | ||
const tx = await client.sendTransaction({ | ||
account: privateKeyToAccount(wallets[0].pkᵻ), | ||
to: item.to, | ||
value: item.amount, | ||
chain, | ||
}); | ||
logger.info(`tx send ${tx}`, { | ||
label: "core/distributeNative", | ||
}); | ||
const time = getRandomArbitrary(2 * 3.6e6, 3 * 3.6e6); | ||
logger.info(`sleep for ${time}`, { | ||
label: "core/distributeNative", | ||
}); | ||
await sleep(time); | ||
} | ||
}; |
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,2 +1,3 @@ | ||
export { mill } from "./miller"; | ||
export { distributeERC } from "./distributeERC"; | ||
export { distributeNative } from "./distributeNative"; |