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
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NETWORK_PRIVATE_KEY=somehexstringwithoutthe0xprefix
NETWORK_RPC_URL=wss://wss.calibration.node.glif.io/apigw/lotus/rpc/v1
17 changes: 13 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,36 @@ on:
branches: [master]
pull_request:

env:
NETWORK_PRIVATE_KEY: ${{ secrets.NETWORK_PRIVATE_KEY }}
NETWORK_RPC_URL: ${{ secrets.NETWORK_RPC_URL }}

jobs:
build:
runs-on: ubuntu-latest
runs-on: ["ubuntu-latest"]
steps:
- name: Checkout 🛎️
uses: "actions/checkout@v4"
with:
submodules: recursive

- name: Install nodejs 🔧
uses: actions/setup-node@v3
with:
node-version: 22.3.0

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install dependencies
run: npm ci

- name: Test
run: npm run test

- name: Build
run: npm run build

- name: Test
run: npm run test

- name: Publish to npmjs
uses: JS-DevTools/npm-publish@v1
if: github.ref == 'refs/heads/master'
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# project files
.env
src/generated

# Compiler files
cache/
out/
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "contracts/lib/forge-std"]
path = contracts/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "randomness-solidity"]
path = randomness-solidity
url = https://github.com/randa-mu/randomness-solidity
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,31 @@
## randomness-js
# randomness-js

A convenience library for retrieving, verifying and deriving randomness from the dcrypt network.

Build everything by running `npm run build`. This creates a dist directory containing commonjs and esm modules.

Solidity interfaces for randomness can be found in our [solidity repo](https://github.com/randa-mu/randamu-solidity-contracts).

## Usage
First install the package by running `npm install randomness-js`
Then create an instance of randomness for your preferred network. An example for filecoin is below:
```javascript
import { JsonRpcProvider, Wallet } from "ethers"
import { Randomness } from "randomness-js"

// set up your ethers objects
const rpc = new JsonRpcProvider("https://api.calibration.node.glif.io/rpc/v1")
const wallet = new Wallet("<YOUR PRIVATE KEY HERE>", rpc)

// create and request some randomness
const randomness = Randomness.createFilecoinCalibnet(wallet)
const response = await randomness.requestRandomness()

// the smart contracts verify the randomness anyway, but doesn't hurt to verify it for yourself to be sure :)
await randomness.verify(response)
```

## Development
- Clone the repo
- run `git submodule update --init --recursive`
For running the tests, you need to create a `.env` file at the project root filling in the fields detailed in [`.env.sample`](./.env.sample).
34 changes: 0 additions & 34 deletions contracts/.github/workflows/test.yml

This file was deleted.

14 changes: 0 additions & 14 deletions contracts/.gitignore

This file was deleted.

66 changes: 0 additions & 66 deletions contracts/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions contracts/foundry.toml

This file was deleted.

1 change: 0 additions & 1 deletion contracts/lib/forge-std
Submodule forge-std deleted from 1eea5b
15 changes: 0 additions & 15 deletions contracts/src/AbstractRandomnessReceiver.sol

This file was deleted.

Loading