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
const ascii85 = require('ascii85'); | |
async function decryptData(account: string, data: Buffer): Promise<Buffer> { | |
// Reconstructing the original object outputed by encryption | |
const structuredData = { | |
version: 'x25519-xsalsa20-poly1305', | |
ephemPublicKey: data.slice(0, 32).toString('base64'), | |
nonce: data.slice(32, 56).toString('base64'), | |
ciphertext: data.slice(56).toString('base64'), | |
}; |
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
import { encrypt } from '@metamask/eth-sig-util'; | |
const ascii85 = require('ascii85'); | |
function encryptData(publicKey: Buffer, data: Buffer): number[] { | |
// Returned object contains 4 properties: version, ephemPublicKey, nonce, ciphertext | |
// Each contains data encoded using base64, version is always the same string | |
const enc = encrypt({ | |
publicKey: publicKey.toString('base64'), | |
data: ascii85.encode(data).toString(), | |
version: 'x25519-xsalsa20-poly1305', |
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
// Account is account address provided as string | |
// App must have access to the specified account | |
const account = "0x012...bc" | |
// Key is returned as base64 | |
const keyB64 = await window.ethereum.request({ | |
method: 'eth_getEncryptionPublicKey', | |
params: [account], | |
}) as string; | |
const publicKey = Buffer.from(keyB64, 'base64'); |
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
import numpy as np | |
import joblib | |
# Load the model, use the correct path to the model.joblib file | |
model = joblib.load("model.joblib") | |
# X should contain the data you want to use for prediction | |
X = np.array([...]) | |
result = model.predict(X) |
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
from sklearn.linear_model import Ridge | |
from felt.builder import upload_model | |
model = Ridge(alpha=0.7) | |
# Make sure you have WEB3_STORAGE_TOKEN environment variable defined | |
cid = upload_model(model) | |
print("CID:", cid) |
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
### Private key of account deploying the smart contracts | |
export PRIVATE_KEY='0xasdfasdfasdfasdfasdfasdfasdfas' | |
### Infura project ID for communicating with network | |
export WEB3_INFURA_PROJECT_ID='aaa5aa5a5a5a55555aaa555a5a5555a' | |
### Polygonscan API token for verifying contracts | |
export POLYGONSCAN_TOKEN='asdfadfasdfsf' |
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
# I recommend using .env file for managing secrets | |
dotenv: .env | |
# set a custom mnemonic for the development network | |
networks: | |
# Polygon | |
polygon-test: | |
link_token: '0x326C977E6efc84E512bB9C30f76E30c160eD06FB' | |
vrf_coordinator: '0x8C7382F9D8f56b33781fE506E897a4F1e2d17255' | |
keyhash: '0x6e75b569a01ef56d18cab6a8e71e6600d6ce853834d4a5748b720d06f878b3a4' |
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
node_modules | |
src/**/*.js |
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
Show hidden characters
{ | |
"env": { | |
"browser": true, | |
"es2021": true | |
}, | |
"extends": [ | |
"plugin:react/recommended", | |
"airbnb", | |
"plugin:@typescript-eslint/recommended" | |
], |
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
{ | |
"compilerOptions": { | |
"target": "es5", | |
"lib": [ | |
"dom", | |
"dom.iterable", | |
"esnext" | |
], | |
"allowJs": true, | |
"skipLibCheck": true, |