Skip to content

daoauth/celo-metamask-signer-sample

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6963a51 · Oct 6, 2020

History

19 Commits
Sep 8, 2020
Sep 8, 2020
Oct 6, 2020
Sep 8, 2020
Sep 8, 2020
Oct 5, 2020
Sep 8, 2020
Sep 8, 2020
Sep 8, 2020
Sep 8, 2020
Sep 8, 2020
Sep 8, 2020
Sep 18, 2020
Sep 8, 2020
Sep 8, 2020
Sep 10, 2020
Sep 10, 2020

Repository files navigation

celo-metamask-signer-sample

Click here for a link to the demo.

sample

swap

Sample Code

index.vue

import { sendTransaction } from '@did-kr-cg/celo-metamask-signer'
const ContractKit = require('@celo/contractkit')
const Web3 = require('web3')

...

async function sendTx () {
  const kit = ContractKit.newKit('https://alfajores-forno.celo-testnet.org')
  let web3 = null

  if (typeof window.ethereum !== 'undefined') {
    await window.ethereum.enable()
    web3 = new Web3(window.ethereum)
  } else {
    return
  }
  const accounts = await this.web3.eth.getAccounts()

  const rawTx = {
    from: accounts[0],
    to: 'TARGET ACCOUNT',
    value: 'VALUE',
    data: 'IF YOU WANT USE SMART CONTRACT'
  }
  const tx = await sendTransaction(kit, web3, rawTx)
  const receipt = await tx.waitReceipt()
  console.log(receipt)
}

Build Setup

# install dependencies
$ yarn install

# serve with hot reload at localhost:3000
$ yarn dev

# build for production and launch server
$ yarn build
$ yarn start

# generate static project
$ yarn generate

For detailed explanation on how things work, check out Nuxt.js docs.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published