Skip to content

Instantly share code, notes, and snippets.

View aesedepece's full-sized avatar
🦾
Building!

Adán SDPC // asdpc.eth aesedepece

🦾
Building!
View GitHub Profile
@aesedepece
aesedepece / witnet-rng-die-example.sol
Last active March 14, 2022 19:03
Witnet RNG roll-a-die simple code snippet
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import "witnet-solidity-bridge/contracts/interfaces/IWitnetRNG.sol";
contract DieContract {
uint32 sides;
struct Guess {
uint32 guessedNumber;
@aesedepece
aesedepece / witnet-dummy-rng-example.sol
Last active December 21, 2021 09:28
Witnet basic RNG example
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import "witnet-solidity-bridge/contracts/interfaces/IWitnetRNG.sol";
contract MyContract {
uint32 public randomness;
uint256 public latestRandomizingBlock;
IWitnetRNG witnet;
@aesedepece
aesedepece / witnet-rng-bytes-example.sol
Last active December 20, 2021 15:35
Witnet basic random bytes example
// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
import "witnet-solidity-bridge/contracts/interfaces/IWitnetRNG.sol";
contract MyContract {
bytes32 public randomness;
uint256 public latestRandomizingBlock;
IWitnetRNG witnet;
@aesedepece
aesedepece / witnet-bitcoin-price-feed-example.sol
Last active December 20, 2021 14:12
Witnet example: read Bitcoin price from Witnet price feed on Ethereum Rinkeby
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;
import "witnet-solidity-bridge/contracts/interfaces/IWitnetPriceFeed.sol";
contract MyContract {
function readBitcoinPriceFromWitnetPriceFeed() external view returns(int256) {
// The address below shall be different for each price feed and blockchain
IWitnetPriceFeed IWitnetPriceFeed = IERC2362(address("0xccAe308C9b91a3e3De8E0Dd4136Ce0Bb608e6ea4"));
@aesedepece
aesedepece / witnet-docker-resync.sh
Created March 27, 2020 12:18
Quick and dirty script for wiping the local chain and resynchronizing a Witnet node running on Docker (see comments)
#!/bin/bash
# If your Docker container is named differently, change it here
CONTAINER="witnet_node"
# If your Witnet storage path is not the default, change it here
STORAGE_PATH="/home/$USER/.witnet"
echo "[ Trying to wipe local chain and resync ]";
echo "1. Making sure the node is running..."
docker start $CONTAINER;
const types: {[key: string]: string} = {
Object: "Object",
String: "String",
Float: "Float"
}
const ops: {[key: string]: string} = {
parseJSON: "parseJSON",
get: "get",
asFloat: "asFloat"
@aesedepece
aesedepece / kvSwap.ts
Last active June 13, 2018 14:11
Safely reverting keys and values in a JS object
const enum ChainType {
test,
main
}
const prefixToChainType: stringToNumber = {
"wit": ChainType.main,
"twit": ChainType.test
}
0x38fdb15a87de55804e8c78f1e7538852b88f4053
0x14134469FC42421C61FC1411e3bEBbb4A0F49d41
0x7F4635Fa1CA8C967Dc22E92F2c73f2CddC42b434