Skip to content

Instantly share code, notes, and snippets.

View boczeratul's full-sized avatar
🎯
Focusing

Hsuan Lee boczeratul

🎯
Focusing
View GitHub Profile
@boczeratul
boczeratul / init_canes.cdc
Created August 8, 2022 01:09
NFT Collection Init Scrips
import NonFungibleToken from 0x1d7e57aa55817448
import Canes_Vault_NFT from 0x329feb3ab062d289
import BloctoStorageRent from 0x1dfd1e5b87b847dc
transaction() {
prepare(signer: AuthAccount) {
// If the account doesn''t already have a collection
if signer.borrow<&Canes_Vault_NFT.Collection>(from: Canes_Vault_NFT.CollectionStoragePath) == nil {
// Create a new empty collection and save it to the account
signer.save(<-Canes_Vault_NFT.createEmptyCollection(), to: Canes_Vault_NFT.CollectionStoragePath)
(async function () {
const event = EVENT;
const apiToken = API_TOKEN;
let hasNextPage = true;
let cursor = '';
while (hasNextPage) {
await fetch('https://query.flowgraph.co', {
method: 'POST',
headers: {
@boczeratul
boczeratul / authorization.js
Created November 3, 2021 12:14
FCL Blocto payer and signature example
import * as fcl from '@onflow/fcl';
import {
signPayer,
signTransaction,
} from './blocto';
const payerSigningFunction = payer_id => data =>
new Promise((resolve) => {
signPayer({ data: data.message, payer_id })
.subscribe(
@boczeratul
boczeratul / setup_account.cdc
Last active October 8, 2021 08:41
Subsidization example
import FlowToken from 0x1654653399040a61
import Beam from "../contracts/Beam.cdc"
import BlockleteGames_NFT from "../contracts/BlockleteGames_NFT.cdc"
import CaaPass from "../contracts/CaaPass.cdc"
import ChainmonstersRewards from "../contracts/ChainmonstersRewards.cdc"
import Collectible from "../contracts/Collectible.cdc"
import Crave from "../contracts/Crave.cdc"
import Everbloom from "../contracts/Everbloom.cdc"
import FantastecNFT from "../contracts/FantastecNFT.cdc"
import FungibleToken from "../contracts/FungibleToken.cdc"
@boczeratul
boczeratul / existing.cdc
Last active August 11, 2021 18:04
Enemy Metal purchase
import FungibleToken from 0xf233dcee88fe0abe
import FlowToken from 0x1654653399040a61
import NonFungibleToken from 0x1d7e57aa55817448
import EnemyMetal from 0xa38d9dda1d06fdea
// This transaction is for buying a NFT mint using flow tokens
transaction(flowAmount: UFix64, payees: [Address], payeesShares: [UFix64], recipient: Address, editionID: UInt64, metadata: String, components: [UInt64], claimEditions: [UInt64], claimMetadatas: [String]) {
let minter: &amp;EnemyMetal.NFTMinter
let buyerVault: &amp;FlowToken.Vault{FungibleToken.Provider}
@boczeratul
boczeratul / TeleportCustody.sol
Created January 7, 2021 02:11
Teleport Custody Contract (Flattened)
// File: @openzeppelin/contracts/GSN/Context.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/*
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
@boczeratul
boczeratul / TeleportAdmin.sol
Last active January 7, 2021 02:09
Teleport Custody Contracts
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there are multiple accounts (admins) that can be granted exclusive access to
* specific functions.
@boczeratul
boczeratul / MessageBoard.cdc
Last active December 4, 2020 22:52
A simple message board contract for Blocto onboarding tutorial
pub contract MessageBoard {
pub struct Post {
pub let timestamp: UFix64
pub let message: String
pub let from: Address
init(timestamp: UFix64, message: String, from: Address) {
self.timestamp = timestamp
self.message = message
self.from = from
import FungibleToken from 0xFUNGIBLETOKENADDRESS
import FlowToken from 0xFLOWTOKENADDRESS
transaction(to: Address) {
// The Vault resource that holds the tokens that are being transferred
let sentVault: @FungibleToken.Vault
prepare(sharedAccount: AuthAccount) {
import FlowToken from 0xFLOWTOKENADDRESS
import FungibleToken from 0xFUNGIBLETOKENADDRESS
import LockedTokens from 0xLOCKEDTOKENADDRESS
/// Transaction that a custody provider would sign
/// to create a shared account for a user who already
/// has their unlocked account created
///
/// The unlocked account has to sign the transaction also