Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ docs/

# Dotenv file
.env

# MacOS files
.DS_Store
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion randomness-solidity
Submodule randomness-solidity updated 1 files
+8 −1 README.md
5 changes: 5 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
NetworkConfig,
configForChainId,
BASE_SEPOLIA,
BASE_MAINNET,
FILECOIN_CALIBNET,
FILECOIN_MAINNET,
POLYGON_POS,
Expand Down Expand Up @@ -237,6 +238,10 @@ export class Randomness {
return new Randomness(rpc, BASE_SEPOLIA)
}

static createBaseMainnet(rpc: Signer | Provider): Randomness {
return new Randomness(rpc, BASE_MAINNET)
}

static createPolygonPos(rpc: Signer | Provider): Randomness {
return new Randomness(rpc, POLYGON_POS)
}
Expand Down
13 changes: 13 additions & 0 deletions src/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ export const BASE_SEPOLIA: NetworkConfig = {
gasMultiplierDefault: 10n,
}

export const BASE_MAINNET: NetworkConfig = {
name: "base_mainnet",
chainId: 8453n,
contractAddress: "0x007cEEc8d8ACa5B0E1f885Ea85077d63b135E651",
dst: "dcipher-randomness-v01-BN254G1_XMD:KECCAK-256_SVDW_RO_0x0000000000000000000000000000000000000000000000000000000000002105_",
gasLimit: 100_000,
maxFeePerGas: ethers.parseUnits("0.2", "gwei"),
maxPriorityFeePerGas: ethers.parseUnits("0.2", "gwei"),
gasBufferPercent: 100n,
callbackGasLimitDefault: 1_000_000n,
gasMultiplierDefault: 10n,
}

export const POLYGON_POS: NetworkConfig = {
name: "polygon_pos",
chainId: 137n,
Expand Down
13 changes: 13 additions & 0 deletions test/randomness.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ describe("randomness", () => {
rpc.destroy()
}, TEST_TIMEOUT)

it.skip("can be requested from a base mainnet and verified", async () => {
const rpc = createProvider(process.env.BASE_RPC_URL || "")
const wallet = new NonceManager(new Wallet(process.env.BASE_PRIVATE_KEY || "", rpc))

const randomness = Randomness.createBaseMainnet(wallet)
expect(randomness).not.toEqual(null)

const response = await randomness.requestRandomness({ callbackGasLimit: 100_000n })
expect(await randomness.verify(response)).toBeTruthy()

rpc.destroy()
}, TEST_TIMEOUT)

it("can be requested from polygon pos and verified", async () => {
const rpc = createProvider(process.env.POLYGON_RPC_URL || "")
const wallet = new NonceManager(new Wallet(process.env.POLYGON_PRIVATE_KEY || "", rpc))
Expand Down
Loading