Skip to content

Commit

Permalink
move server
Browse files Browse the repository at this point in the history
  • Loading branch information
notV4l committed Oct 15, 2024
1 parent 2f7811b commit 788790a
Show file tree
Hide file tree
Showing 22 changed files with 63 additions and 191 deletions.
40 changes: 2 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,3 @@
## Run server
## Documentation

`cargo run`

## Get server's public key

`GET http://0.0.0.0:3000/info`

## Get random numbers

```js
const response = await fetch("http://0.0.0.0:3000/stark_vrf", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ seed: ["0x5733e5c2c8030bc06888747525b1a1f0242ca770c9387b58a4529df0ca55499"] }),
});
const json = await response.json();
```

which will return:

```js
{
"result": {
"gamma_x": "0x6ac32f9b3c0bef88e4e1ba77d2f77fa603bbd4b42cca6405c5bdf7a16821d75",
"gamma_y": "0x50e3875635d84cb0038dbccb309b1134e101aee38c02001e456d5988b39fd43",
"c": "0x111fd321fb9b48c651a871fcfeea71a0f521ba04fe54f81caf2f407cba0979f",
"s": "0x437d280a8eb8e1e57c291af359738118c5b64b00ff5bd209d86ef83b051a2c6",
"sqrt_ratio": "0xa99242633a4f2a7b31c4c7d3bee93dad3bd946a68cfac753dbd4bbd837d8c0",
"rnd": "0x41c6b570b6720f205da6ef692021fe3625bbbab1ef5ea0ecea470e2d93b7982"
}
}
```

## Verify proof in Cairo

See https://github.com/dojoengine/stark-vrf
[Cartridge VRF Documentation](https://docs.cartridge.gg/vrf/overview)
22 changes: 16 additions & 6 deletions Scarb.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
[workspace]
members = ["contracts"]

[workspace.package]
[package]
name = "cartridge_vrf"
version = "0.1.0"
edition = "2023_10"

[workspace.dependencies]
[dependencies]
starknet = "2.7.0"
stark_vrf = { git = "https://github.com/dojoengine/stark-vrf.git" }
openzeppelin = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "a13bae3" }
snforge_std = { git = "https://github.com/foundry-rs/starknet-foundry.git", tag = "v0.26.0" }
# Scripts are not supported for virtual workspaces.

[dev-dependencies]
openzeppelin_testing = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "a13bae3" }
openzeppelin_utils = { git = "https://github.com/OpenZeppelin/cairo-contracts.git", rev = "a13bae3" }

[[target.starknet-contract]]
allowed-libfuncs-list.name = "experimental"

[lib]

[script]
test = "snforge test"
3 changes: 0 additions & 3 deletions contracts/README.md

This file was deleted.

117 changes: 0 additions & 117 deletions contracts/Scarb.lock

This file was deleted.

24 changes: 0 additions & 24 deletions contracts/Scarb.toml

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
39 changes: 39 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
## Run server

`cargo run`

## Get server's public key

`GET http://0.0.0.0:3000/info`

## Get random numbers

```js
const response = await fetch("http://0.0.0.0:3000/stark_vrf", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ seed: ["0x5733e5c2c8030bc06888747525b1a1f0242ca770c9387b58a4529df0ca55499"] }),
});
const json = await response.json();
```

which will return:

```js
{
"result": {
"gamma_x": "0x6ac32f9b3c0bef88e4e1ba77d2f77fa603bbd4b42cca6405c5bdf7a16821d75",
"gamma_y": "0x50e3875635d84cb0038dbccb309b1134e101aee38c02001e456d5988b39fd43",
"c": "0x111fd321fb9b48c651a871fcfeea71a0f521ba04fe54f81caf2f407cba0979f",
"s": "0x437d280a8eb8e1e57c291af359738118c5b64b00ff5bd209d86ef83b051a2c6",
"sqrt_ratio": "0xa99242633a4f2a7b31c4c7d3bee93dad3bd946a68cfac753dbd4bbd837d8c0",
"rnd": "0x41c6b570b6720f205da6ef692021fe3625bbbab1ef5ea0ecea470e2d93b7982"
}
}
```

## Verify proof in Cairo

See https://github.com/dojoengine/stark-vrf
File renamed without changes.
File renamed without changes.
5 changes: 4 additions & 1 deletion contracts/src/lib.cairo → src/lib.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pub mod vrf_consumer {
pub mod vrf_consumer_component;
}

pub mod mocks {
pub mod vrf_consumer_mock;
}

pub use vrf_provider::vrf_provider_component::{
IVrfProvider, IVrfProviderDispatcher, IVrfProviderDispatcherTrait, PublicKey, Source
};
Expand All @@ -16,5 +20,4 @@ pub use vrf_consumer::vrf_consumer_component::VrfConsumerComponent;
pub mod tests {
pub mod common;
pub mod test_dice;
pub mod vrf_consumer_mock;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use cartridge_vrf::vrf_provider::vrf_provider_component::{
IVrfProvider, IVrfProviderDispatcher, IVrfProviderDispatcherTrait, PublicKey,
};

use super::vrf_consumer_mock::{
use cartridge_vrf::mocks::vrf_consumer_mock::{
VrfConsumer, IVrfConsumerMock, IVrfConsumerMockDispatcher,
IVrfConsumerMockDispatcherTrait
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use cartridge_vrf::{
IVrfProvider, IVrfProviderDispatcher, IVrfProviderDispatcherTrait, PublicKey, Source
};

use super::vrf_consumer_mock::{
use cartridge_vrf::mocks::vrf_consumer_mock::{
VrfConsumer, IVrfConsumerMock, IVrfConsumerMockDispatcher,
IVrfConsumerMockDispatcherTrait
};
Expand Down
File renamed without changes.

0 comments on commit 788790a

Please sign in to comment.