-
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
606701b
commit 8f87400
Showing
4 changed files
with
46 additions
and
2 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,3 +1,4 @@ | ||
DATABASE_URL= | ||
MAX_BLOCK_RANGE= | ||
AVALANCHE_RPC= | ||
AVALANCHE_RPC= | ||
ORACLE_PRIVATE_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
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,36 @@ | ||
import { createWalletClient, http } from "viem"; | ||
import { privateKeyToAccount } from "viem/accounts"; | ||
import { mainnet } from "viem/chains"; | ||
import getMerkleRoot from "./merkle.cjs"; | ||
|
||
import { parseAbi } from "viem"; | ||
|
||
const abi = parseAbi([ | ||
"function setMerkleRoot(bytes32 _merkleRoot)", | ||
"function s_merkleRoot() view returns (bytes32)", | ||
]); | ||
|
||
const KEY = process.env.ORACLE_PRIVATE_KEY || ""; | ||
|
||
async function sync() { | ||
const account = privateKeyToAccount(KEY); | ||
|
||
const client = createWalletClient({ | ||
account, | ||
chain: mainnet, | ||
transport: http(), | ||
}); | ||
|
||
const root = await getMerkleRoot(43114); | ||
|
||
const tx = await client.writeContract({ | ||
address: "0x", | ||
abi: abi, | ||
functionName: "setMerkleRoot", | ||
args: [root], | ||
}); | ||
|
||
console.log(tx); | ||
} | ||
|
||
sync().catch(console.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