Skip to content

Instantly share code, notes, and snippets.

View Perseverance's full-sized avatar
🪄

George Spasov Perseverance

🪄
View GitHub Profile
const ethEcies = require('eth-ecies');
function encrypt(publicKey, userData) {
let userPublicKey = new Buffer(publicKey, 'hex');
let bufferUserData = new Buffer(userData);
let encryptedUserData = ethEcies.encrypt(userPublicKey, bufferUserData);
return encryptedUserData.toString('base64');
}
<script src="https://unpkg.com/ipfs/dist/index.js"></script>
const node = new Ipfs()
node.on('ready', () => {
console.log('IPFS Ready');
const file = 'File contents';
let fileBuffer = new buffer.Buffer(file);
node.files.add(fileBuffer, (err, hash) => {
<script src="https://unpkg.com/ipfs/dist/index.js"></script>
const node = new Ipfs()
node.on('ready', () => {
console.log("IPFS Ready");
});
pragma solidity 0.4.15;
contract SharedStorage {
address public contractImplementation;
}
contract Forwardable {
/**
* @dev Performs a delegatecall and returns whatever the delegatecall returned (entire context execution will return!)
* @param _dst Destination address to perform the delegatecall
pragma solidity ^0.4.20;
contract KeyValueStorage {
mapping(bytes32=>uint256) public uints;
mapping(bytes32=>bytes32) public bytes32s;
mapping(bytes32=>bool) public bools;
// And any other type you like
modifier onlyWhitelisted() {
_;