Skip to content

Instantly share code, notes, and snippets.

View abto-software's full-sized avatar

Abto Software abto-software

View GitHub Profile
@abto-software
abto-software / Deploying the Profile.cdc
Created August 29, 2022 10:16
Creating first smart contract, "How to create a ReactJS dApp" blog
flow project deploy --update
@abto-software
abto-software / Updating content.js
Created August 29, 2022 10:03
Adding the cadence script and the blockchain transaction to the AppJS component, "How to create a ReactJS dApp" blog
import * as fcl from "@onflow/fcl";
import * as t from "@onflow/types"
import './App.css';
import { useEffect, useState } from "react";
fcl
.config()
// Point App at Emulator REST API
.put("accessNode.api", "http://localhost:8888")
@abto-software
abto-software / Creating the blockchain transaction.js
Created August 29, 2022 10:01
Creating first blockchain transaction, "How to create a ReactJS dApp" blog
const updateProfile = async () => {
const txId = await fcl.send(
[
fcl.transaction`
import Profile from 0xProfile
transaction(newFirstName: String, newLastName: String, newEmail: String) {
prepare(signer: AuthAccount) {
@abto-software
abto-software / Extracting data from the blockchain network.js
Created August 29, 2022 10:00
Creating first cadence script, "How to create a ReactJS dApp" blog
const getProfile = async () => {
const [firstName, lastName, email] = await fcl.send([
fcl.script`
import Profile from 0xf8d6e0586b0a20c7
pub fun main(): [String] {
return [Profile.firstName, Profile.lastName, Profile.email]
}
`
]).then(fcl.decode)
@abto-software
abto-software / fcl-dev-wallet.js
Created August 29, 2022 09:58
Running the local emulator with the dev wallet, "How to create a ReactJS dApp" blog
flow emulator
npm run dev
@abto-software
abto-software / fcl-dev-wallet flow.json
Created August 29, 2022 09:56
Adding the smart contract to the configuration file of the fcl-dev-wallet/flow.json directory, "How to create a ReactJS dApp" blog
{
"contracts": {
"Profile": {
"source": "./cadence/contracts/Profile.cdc"
"aliases": {
"emulator": "0xee82856bf20e2aa6"
}
},
@abto-software
abto-software / Installing the OnFlow packages.js
Created August 29, 2022 09:54
Installing the OnFlow packages for my-first-dapp, "How to create a ReactJS dApp" blog
npm i @onflow/fcl @onflow/types
@abto-software
abto-software / my-first-dapp.js
Created August 29, 2022 09:52
Setting up ReactJS dApp, for "How to create a ReactJS dApp" blog
npx create-react-app my-first-dapp
@abto-software
abto-software / log-in and log-out.js
Created August 29, 2022 09:49
code example for "ReactJS dApp" article
import * as fcl from "@onflow/fcl";
import './App.css';
import { useEffect, useState } from "react";
fcl
.config()
// Point App at Emulator REST API
.put("accessNode.api", "http://localhost:8888")
// Point FCL at dev-wallet (default port)