Skip to content

Instantly share code, notes, and snippets.

View Th0rgal's full-sized avatar
🕶️

Thomas Marchand Th0rgal

🕶️
View GitHub Profile
@Th0rgal
Th0rgal / felt_to_hex.rs
Created August 2, 2023 13:33
An efficient function to convert a FieldElement in a fixed size hexadecimal representation
pub fn to_hex(felt: FieldElement) -> String {
let bytes = felt.to_bytes_be();
let mut result = String::with_capacity(bytes.len() * 2 + 2);
result.push_str("0x");
for byte in bytes {
write!(&mut result, "{:02x}", byte).unwrap();
}
result
}
You are an experienced data scientist used to working with matplotlib in a jupyter notebook environment. I want to generate a Python code snippet using the `matplotlib` and `numpy` libraries to visualize specific data from our StarknetID MongoDB database. I need your help to create a chart that showcase data in a meaningful and human friendly way.
Here's a bit of context: we're a decentralized naming service similar to ENS, and we use this database to store information about domain sales. Each document in our "sales" collection contains the following fields:
"domain": the name of the domain that was sold
"type": the type of the sale (can be "purchase" or "renewal")
"price": the price paid by the buyer in ether wei
"timestamp": the time when the sale happened, represented in seconds
"duration": the duration of the domain rent, in seconds
"auto": a boolean indicating whether the domain was purchased automatically (true if the user activated the automatic renewal feature)
rapp-multicall v0.1.0 (/app/rapp-multicall)
├── heapless v0.7.16
│ ├── hash32 v0.2.1
│ │ └── byteorder v1.4.3
│ └── stable_deref_trait v1.2.0
│ [build-dependencies]
│ └── rustc_version v0.4.0
│ └── semver v1.0.17
├── nanos_sdk v0.2.0 (https://github.com/yogh333/ledger-nanos-sdk.git?branch=feat/libcall_support#6ab1660c)
│ ├── num-traits v0.2.15
pragma solidity ^0.4.0;
contract ECops {
uint256 constant n = 0x30644E72E131A029B85045B68181585D97816A916871CA8D3C208C16D87CFD47;
uint256 constant a = 0;
uint256 constant b = 3;
// Returns the inverse in the field of modulo n
function inverse(uint256 num) public pure returns(uint256 invNum) {
uint256 t = 0;
# [input trace:]
# p.x
# p.y
# p.infinity
# q.x
# q.y
# q.infinity
# [appended trace:]
# coef -> coef * (trace[ap - 3] - trace[ap - 6]) - (trace[ap - 2] - trace[ap - 5]) = 0
%lang starknet
from starkware.cairo.common.math import assert_nn
from starkware.cairo.common.cairo_builtins import HashBuiltin
struct Call {
to: felt,
selector: felt,
data_offset: felt,
data_len: felt,
}
Error at pc=0:0:
Got an exception while executing a hint.
Cairo traceback (most recent call last):
Unknown location (pc=0:2)
Traceback (most recent call last):
File "<hint0>", line 9, in <module>
File "protostar/migrator/cheatcodes/migrator_declare_cheatcode.py", line 118, in _declare
File "asyncio/runners.py", line 44, in run
File "asyncio/base_events.py", line 647, in run_until_complete
from starknet_py.net.gateway_client import GatewayClient
from starknet_py.net import AccountClient
from starknet_py.contract import Contract
from starknet_py.net.signer.stark_curve_signer import KeyPair
from starkware.starknet.definitions.general_config import StarknetChainId
from starkware.starknet.public.abi import get_selector_from_name
import asyncio
abi = [
{
[
{
"members": [
{
"name": "low",
"offset": 0,
"type": "felt"
},
{
"name": "high",
%lang starknet
from starkware.cairo.common.uint256 import Uint256
from src.game import GameData
@contract_interface
namespace IGasLessLiar {
func deposit(amount: Uint256) {
}