Skip to content

Instantly share code, notes, and snippets.

View pedrouid's full-sized avatar
🛠️
Building @WalletConnect

Pedro Gomes pedrouid

🛠️
Building @WalletConnect
View GitHub Profile
@pedrouid
pedrouid / transaction.js
Created July 10, 2019 20:35
Transaction formatting
"use strict";
const BigNumber = window.BigNumber;
const TOKEN_TRANSFER = "0xa9059cbb";
const DAI_TOKEN_ADDRESS = "0x89d24A6b4CcB1B6fAA2625fE562bDD9a23260359";
function convertAmountToRawNumber(value, decimals = 18) {
return new BigNumber(`${value}`)
.times(new BigNumber("10").pow(decimals))
@pedrouid
pedrouid / transaction.ts
Created July 9, 2019 18:31
Ethereum Transaction Formatting
import { convertNumberToHex, convertUtf8ToNumber } from "@walletconnect/utils";
import { convertAmountToRawNumber } from "../helpers/bignumber";
import {
apiGetAccountNonce,
// apiGetGasLimit,
apiGetGasPrices
} from "../helpers/api";
import {
getDataString,
removeHexPrefix,
@pedrouid
pedrouid / install.sh
Created July 7, 2019 21:56
Installing Web3Connect with NPM or Yarn
npm install --save web3connect
# OR
yarn add web3connect
@pedrouid
pedrouid / index.js
Last active July 7, 2019 21:59
Integrating Web3Connect with Core Module
import Web3Connect from "web3connect";
const web3Connect = new Web3Connect.Core({
providerOptions: {
portis: {
id: "PORTIS_ID", // required
network: "mainnet" // optional
},
fortmatic: {
key: "FORTMATIC_KEY", // required
@pedrouid
pedrouid / index.js
Last active July 7, 2019 21:58
Integrating Web3Connect with React button
import Web3Connect from "web3connect";
<Web3Connect.Button
providerOptions={{
portis: {
id: "PORTIS_ID", // required
network: "mainnet" // optional
},
fortmatic: {
key: "FORTMATIC_KEY", // required
@pedrouid
pedrouid / twoFactor.js
Created May 14, 2019 21:01
2FA Authentication Methods
const crypto = require('crypto');
const b32 = require('thirty-two');
const notp = require('notp');
/**
* @desc generate TOTP secret
* @param {String} [email]
* @return {String}
*/
const generateSecret = email => {
@pedrouid
pedrouid / walletconnect-instant.md
Last active April 28, 2022 23:40
WalletConnect Instant ⚡

WalletConnect Instant ⚡

What's an Instant Request?

WalletConnect Instant feature introduces the ability to make an ephemeral session that bypasses the process of session approval by the wallet, displaying to the user a call request to be signed from the Dapp right after scanning the QR Code. This is useful for one-time use-cases like payments, topping-up or withdrawals. This is still highly experimental and hasn't been published to the official library. A PoC to aggregate feedback on this feature!

Source code available at WalletConnect/walletconnect-monorepo on walletconnect-instant branch.

Install

@pedrouid
pedrouid / getLocalIpAddress.js
Last active July 18, 2020 15:53
Get Local IP Address from Browser (inspired by net.ipcalf.com)
function getLocalIpAddress() {
return new Promise(function (resolve, reject) {
var RTCPeerConnection = window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
if (RTCPeerConnection) {
var rtc = new RTCPeerConnection({iceServers: []});
if (1 || window.mozRTCPeerConnection) { // FF [and now Chrome!] needs a channel/stream to proceed
rtc.createDataChannel('', {reliable: false});
};
did:muport:QmQ3fkGTPi7wWSFqMBr9fTf4b4BRtLQXDHoiABGNjmf4MV
@pedrouid
pedrouid / 3box-verify.md
Created February 25, 2019 18:55
3box verify

did:muport:QmQ3fkGTPi7wWSFqMBr9fTf4b4BRtLQXDHoiABGNjmf4MV