Skip to content

Instantly share code, notes, and snippets.

View Ankarrr's full-sized avatar
👨‍💻
Building

Anderson Chen Ankarrr

👨‍💻
Building
View GitHub Profile
import { ethers } from 'ethers';
const priKey = '';
// Contract info
const personalWalletAddress = '0x4378Faec5cCfCC6B9E1A8174435eB4354398EDdd';
// eslint-disable-next-line object-curly-newline
const personalWalletAbi = [{ constant: false, inputs: [ { name: '_to', type: 'address[]' }, { name: '_value', type: 'uint256[]' }, { name: '_idx', type: 'uint256[]' }, { name: '_data', type: 'bytes' }, { name: '_nonce', type: 'uint256' }, { name: '_v', type: 'uint8' }, { name: '_r', type: 'bytes32' }, { name: '_s', type: 'bytes32' } ], name: 'batchDelegateExecute', outputs: [], payable: false, stateMutability: 'nonpayable', type: 'function' }, { constant: false, inputs: [ { name: '_to', type: 'address[]' }, { name: '_value', type: 'uint256[]' }, { name: '_idx', type: 'uint256[]' }, { name: '_data', type: 'bytes' } ], name: 'batchExecute', outputs: [], payable: false, stateMutability: 'nonpayable', type: 'function' }, { constant: false, inputs: [ { name: '_to', type: 'address' }, { name: '_value', type: 'uint256' }, {
import { ethers } from 'ethers';
import web3 from 'web3-utils';
const priKey = 'xxxxx';
const personalWalletAddress = '0xC1Ad71338509982d1E5738CfC09F5975B5c7d9fd';
// eslint-disable-next-line object-curly-newline
const personalWalletAbi = [{ constant: false, inputs: [ { name: '_to', type: 'address[]' }, { name: '_value', type: 'uint256[]' }, { name: '_idx', type: 'uint256[]' }, { name: '_data', type: 'bytes' }, { name: '_nonce', type: 'uint256' }, { name: '_v', type: 'uint8' }, { name: '_r', type: 'bytes32' }, { name: '_s', type: 'bytes32' } ], name: 'batchDelegateExecute', outputs: [], payable: false, stateMutability: 'nonpayable', type: 'function' }, { constant: false, inputs: [ { name: '_to', type: 'address[]' }, { name: '_value', type: 'uint256[]' }, { name: '_idx', type: 'uint256[]' }, { name: '_data', type: 'bytes' } ], name: 'batchExecute', outputs: [], payable: false, stateMutability: 'nonpayable', type: 'function' }, { constant: false, inputs: [ { name: '_to', type: 'address' }, { name: '_value', ty
pragma experimental ABIEncoderV2;
pragma solidity ^0.5.0;
contract Verifier {
mapping (address => uint) public smiles;
mapping (address => uint) public nods;
function nod(address nodder, uint nodNum, uint nodMultiplier) public {
nods[nodder] = nods[nodder]*nodMultiplier + nodNum;
}
pragma experimental ABIEncoderV2;
pragma solidity ^0.5.0;
contract Verifier {
bytes32 constant SALT = 0xf2d857f4a3edcb9b78b4d503bfe733db1e3f6cdc2b7971ee739626c97e86a558; // Finally method to identify Dapp
uint256 chainId = 3; // Ropsten testnet
string private constant EIP712_DOMAIN = "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract,bytes32 salt)";
bytes32 private constant EIP712_DOMAIN_TYPEHASH = keccak256(abi.encodePacked(EIP712_DOMAIN));
bytes32 private DOMAIN_SEPARATOR = keccak256(abi.encode(
function parseSignature(signature) {
var r = signature.substring(0, 64);
var s = signature.substring(64, 128);
var v = signature.substring(128, 130);
return {
r: "0x" + r,
s: "0x" + s,
v: parseInt(v, 16)
}
if (!global.btoa) {
global.btoa = function (str) {
return new Buffer(str, 'binary').toString('base64');
};
}
if (!global.atob) {
global.atob = function (b64Encoded) {
return new Buffer(b64Encoded, 'base64').toString('binary');
};
// Dapp SDK
window.ethereum.isDappSdk
> True
window.ethereum.dappSdk.version
> "0.1.0"
// MetaMask
window.ethereum.isMetaMask
> True
await window.ethereum.logout();
await window.ethereum.enable();
<script src='https://storage.googleapis.com/dappsdk/dapp-sdk.bundle.js'></script>