Tutorial
Run a simple dApp that uses Blocto wallet service
Hello World
Step 1 - Create app and setup dependencies
$ npx create-react-app hello-world$ yarn add @blocto/fcl@^1.4.0
$ yarn add styled-components$ yarn startStep 2 - Read from Flow
import React, {useState} from "react"
import * as fcl from "@blocto/fcl"
import styled from 'styled-components'
const Card = styled.div`
margin: 10px 5px;
padding: 10px;
border: 1px solid #c0c0c0;
border-radius: 5px;
`
const Code = styled.pre`
background: #f0f0f0;
border-radius: 5px;
max-height: 150px;
overflow-y: auto;
padding: 5px;
`
const GetLatestBlock = () => {
const [data, setData] = useState(null)
const runGetLatestBlock = async (event) => {
event.preventDefault()
const response = await fcl.send([
fcl.getBlock(true)
])
setData(await fcl.decode(response))
}
return (
<Card>
<button onClick={runGetLatestBlock}>
Get Latest Block
</button>
{data && <Code>{JSON.stringify(data, null, 2)}</Code>}
</Card>
)
}
export default GetLatestBlockStep 3 - Connect to Blocto wallet
Step 4 - Send a simple transaction
Other Resources
Last updated
Was this helpful?