Skip to content

Instantly share code, notes, and snippets.

View vivekascoder's full-sized avatar
💭
Learning

Vivek vivekascoder

💭
Learning
View GitHub Profile
contract Root {
// calculates a^(1/n) to dp decimal places
// maxIts bounds the number of iterations performed
function nthRoot(uint _a, uint _n, uint _dp, uint _maxIts) pure public returns(uint) {
assert (_n > 1);
// The scale factor is a crude way to turn everything into integer calcs.
// Actually do (a * (10 ^ ((dp + 1) * n))) ^ (1/n)
// We calculate to one extra dp and round at the end
This file has been truncated, but you can view the full file.
[
{
"address": {
"ens_domain_name": null,
"hash": "0xf338f45A7EdA247340bB018288Caa7Fb4266E5ac",
"implementation_name": null,
"is_contract": false,
"is_verified": null,
"metadata": null,
"name": null,
[
{
"address": {
"ens_domain_name": null,
"hash": "0x9a6C2890024F6fa7a61EbaD3Cc42a3Cd1cEEFF9C",
"implementation_name": null,
"is_contract": false,
"is_verified": null,
"metadata": null,
"name": null,
[
{
"address": {
"ens_domain_name": null,
"hash": "0x00DDC08D535918425709DA3e50134AE7CFb2eFf9",
"implementation_name": null,
"is_contract": false,
"is_verified": null,
"metadata": null,
"name": null,
{
"type": "Strategy",
"data": {
"cron": "* ** ",
"cronjob": {
"type": "Weighted",
"data": [
{
"type": "Weight",
{
"editor.minimap.enabled": false,
"workbench.startupEditor": "none",
"vim.easymotion": true,
"vim.incsearch": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
"vim.insertModeKeyBindings": [
{
{
"editor.minimap.enabled": false,
"breadcrumbs.enabled": false,
"workbench.startupEditor": "none",
"vim.easymotion": true,
"vim.incsearch": true,
"vim.useSystemClipboard": true,
"vim.useCtrlKeys": true,
"vim.hlsearch": true,
"vim.insertModeKeyBindings": [
module 0x3::token {
...
struct TokenId has store, copy, drop {
token_data_id: TokenDataId,
property_version: u64,
}
struct TokenDataId has copy, drop, store {
creator: address,
public entry fun mint_nft(account: &signer) acquires ResourceSigner, MintingInfo {
let (resource, resource_addr) = resource_account();
let minting_info = borrow_global_mut<MintingInfo>(@rangers);
let name = string::utf8(b"");
string::append(&mut name, minting_info.base_name);
string::append(&mut name, to_string(minting_info.index));
let img = generate_base64_image(minting_info.index);
let uri = generate_base64_metadata(img, minting_info.index);
std::debug::print(&uri);
@vivekascoder
vivekascoder / hasher.rs
Created December 25, 2022 13:51
implementing Hash trait for a struct.
use std::hash::{Hash, Hasher};
use std::collections::hash_map::DefaultHasher;
#[derive(Debug)]
struct A {
a: i32
}
impl Hash for A {