Skip to content

Instantly share code, notes, and snippets.

@imyourm8
imyourm8 / bip39-loom.cs
Last active June 20, 2018 09:56
Generate Private Key for Loom Using BIP39
// Add this function to Loom SDK CryptoUtils.cs
public static byte[] GeneratePrivateKey(byte[] seed) {
byte[] publicKey32;
byte[] privateKey64;
Ed25519.KeyPairFromSeed(out publicKey32, out privateKey64, seed);
return privateKey64;
}
// You can use any BIP39 implementation. In this example i used https://github.com/ByronAP/BIP39.NET-Portable
var mnemonic = "spin sunset pact nature enhance include fatigue occur blind wire inner foot";
@imyourm8
imyourm8 / bip39+bip32.cs
Created June 23, 2018 10:41
BIP39 & BIP32 C# example implementation
/*
This code allows you to export BIP39 12 words phrase and use it with Ethereum/Loom
To check Popular derivative paths look here https://www.myetherwallet.com/#view-wallet-info
Or here is quick cheatsheet https://gyazo.com/a4199116750b57a02917eb255d4c033e
Dependency on very nice library https://github.com/MetacoSA/NBitcoin - clone and build it
*/
using NBitcoin;
// SPDX-License-Identifier: UNLICENSED
// File contracts/lib/IERC20.sol
pragma solidity 0.7.3;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
function totalSupply() external view returns (uint256);
Jan 23 09:42:35 matic-validator bash[8738]: INFO [01-23|09:42:35.039] Imported new chain segment blocks=1 txs=0 mgas=0.000 elapsed="888.502µs" mgasps=0.000 number=9945715 hash="341755…425a20" dirty=253.04MiB
Jan 23 09:42:35 matic-validator bash[8738]: ERROR[01-23|09:42:35.039] Failed to prepare header for mining err="Signer 0x28c0d4328520ed7e8657de141eee74a954b07c1f is not a part of the producer set at block 9945715"
Jan 23 09:42:36 matic-validator bash[8738]: INFO [01-23|09:42:36.632] Imported new chain segment blocks=1 txs=0 mgas=0.000 elapsed="486.88µs" mgasps=0.000 number=9945716 hash="7d2d78…570464" dirty=253.04MiB
Jan 23 09:42:36 matic-validator bash[8738]: ERROR[01-23|09:42:36.632] Failed to prepare header for mining err="Signer 0x28c0d4328520ed7e8657de141eee74a954b07c1f is not a part of the producer set at block 9945716"
Jan 23 09:42:39 matic-validator bash[8738]: INFO [01-23|09:42:39.296] Imported new chain segment block
// File: openzeppelin-solidity/contracts/math/SafeMath.sol
pragma solidity ^0.5.2;
/**
* @title SafeMath
* @dev Unsigned math operations with safety checks that revert on error
*/
library SafeMath {
0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000a67f90a648407d6fd10b901405983bba99fe717339004f2000c63bd79f2b271578f15651459486e6b3a061ec1d6c30b9e98f548acb1631f1623c4c7517bcc9186122100dfc8565095b900aea2795898e224cb99ee50ed5e6a19330faec92e4714b43d17e7b8c0d7f61885881768606599fcc3933ecaa6275909a85f2625203b03f4aef4e1fd053264b999aa306c0ece9bb46db273b7b63845204a0ac78a98b3c109a22bf2abeaf8f3cd2c2cf480382de53056013bbd362f516d675eeac92ee682d932b1a8d2d0a7ee9e006344ae31af712c7c6082ba69de19befbec1fedc066ecf8b2b42ceb7de9f591bcecff3917e253b637ec99e36babf4caca41d1385baf8d60ddc020381b784e9ff77540f2c122e81403aba7b9b3a1da6f98d710f9209511f33638aa6cb3541b7d94ef6717f091661485a4b21f39d1545d887cde7810bb710676b4c22b7f3a75466c83a183e92f0f8460b8c22fa0970004dc6c361f193e243f7fe639b7817d8a7628d935fb34512a419c67606ee1a04a1e644da4e60432fcc87e2a82377a08e3b0a929307b81e88fe123458db936c7b902ebf902e80183570becb90100000000000000000000000000000000000000000000200000000000
"col_red_snake": "Red Snake",
"col_black_snake": "Black Snake",
"earth_slime": "Earth slime",
"dark_slime": "dark slime",
"light_slime": "light slime",
"water_slime": "water slime",
"skull_tree": "skull tree",
"ventoss": "ventoss",
"slime_buffer": "slime buffer",
"slime_healer": "slime healer",