Skip to content

Instantly share code, notes, and snippets.

Matthew Black mattBlackDesign

Block or report user

Report or block mattBlackDesign

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Atomic Loans Demo Txs
Request Loan:
Lock Collateral:
Withdraw Loan:
ERC20 Approve:
Repay Loan:
Unlock Collateral:
mattBlackDesign / ERC20Loan.sol
Created Nov 15, 2018
TAL ERC20Loan Contract
View ERC20Loan.sol
import './ExampleCoin.sol';
pragma solidity ^0.4.21;
contract ERC20Loan {
uint public principle;
uint public interest;
address public lender;
address public borrower;
View ERC20SwapProviderSetup.js
const ethereum = new Client()
ethereum.addProvider(new ERC20SwapProvider(tokenContractAddress, web3))
await ethereum.initiateSwap(1, recipientAddress, refundAddress, secretHash, expiration)
View ERC20SwapProvider.js
import ERC20Swap from "../contracts/ERC20Swap.json";
import ExampleCoin from "../contracts/ExampleCoin.json";
import truffleContract from "truffle-contract";
import getWeb3 from "./getWeb3";
export default class ERC20SwapProvider {
constructor (tokenAddress, web3) {
this._tokenAddress = tokenAddress;
this._web3 = web3
View ERC20.sol
import "./tokens/EIP20.sol";
pragma solidity ^0.4.21;
contract ERC20Swap {
bytes32 keyHash;
uint expiration;
address deployer;
address recipient;
address tokenAddress;
View cal-ledger.js
import { Client, providers } from 'chainabstractionlayer'
const { EthereumRPCProvider, EthereumLedgerProvider } = providers.ethereum
const ethereum = new Client()
ethereum.addProvider(new EthereumRPCProvider('http://localhost:8545', 'ethereum', 'local321'))
ethereum.addProvider(new EthereumLedgerProvider())
View if-else.js
var blockData
if (chain === 'bitcoin') {
var blockHash = await bitcoin.rpc.getblockhash(blockNum)
blockData = await bitcoin.rpc.getblock(blockHash)
// Normalize bitcoin data
blockData.number = blockData.height
blockData.timestamp = blockData.time
blockData.parentHash = blockData.previousblockhash
View intro.js
import { Client, providers, networks } from 'chainabstractionlayer'
const { BitcoinRPCProvider, BitcoinLedgerProvider } = providers.bitcoin
const { EthereumRPCProvider, EthereumLedgerProvider } = providers.ethereum
const bitcoin = new Client()
bitcoin.addProvider(new BitcoinRPCProvider('http://localhost:8080', 'bitcoin', 'local321'))
bitcoin.addProvider(new BitcoinLedgerProvider({ network: networks.bitcoin }))
const ethereum = new Client()
ethereum.addProvider(new EthereumRPCProvider('http://localhost:8545', 'ethereum', 'local321'))
View IOwned.sol
contract IOwned {
// this function isn't abstract, since the compiler emits automatically generated getter functions as external
function owner() public view returns (address) {}
function transferOwnership(address _newOwner) public;
function acceptOwnership() public;
View web3-ledger.js
var Web3 = require('web3')
var ProviderEngine = require('web3-provider-engine')
var RpcSubprovider = require('web3-provider-engine/subproviders/rpc')
var LedgerWalletSubproviderFactory = require('ledger-wallet-provider').default
var engine = new ProviderEngine()
var web3 = new Web3(engine)
var ledgerWalletSubProvider = async LedgerWalletSubproviderFactory()
You can’t perform that action at this time.