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: https://kovan.etherscan.io/tx/0x093d4854f34647c764f32ded2c9595a018d5d48282ee4e4a9ae5c073b068d451
Lock Collateral: https://blockstream.info/testnet/tx/f4e139634aef6896bd940df4439263f087054532bb49ecf0ff5aaba307d70d02
Withdraw Loan: https://kovan.etherscan.io/tx/0x8de4def0b81e5cc27a9be71b5b6e7716916200c45befb8fca59ec0953c5c26d7
ERC20 Approve: https://kovan.etherscan.io/tx/0x4046eafad114ee86f2e69b2470fb68fd9962d41cdf073d0925f8757d7a263504
Repay Loan: https://kovan.etherscan.io/tx/0xfa10ea047bb936360b6c19af250777e63c652b3f246e49bddb0d35da6a59f20c
Unlock Collateral: https://blockstream.info/testnet/tx/2585b1b54b30194f2c9d24e2ad6bfec2e44598bbc340d5b26624b29dc92b9635
@mattBlackDesign
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())
ethereum.getAddresses().then(console.log)
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()
engine.addProvider(ledgerWalletSubProvider)
You can’t perform that action at this time.