├── .circleci └── config.yml ├── .gitignore ├── README.md ├── contracts ├── ethereum │ ├── .gitignore │ ├── README.md │ ├── contracts │ │ ├── TeleportCustody.sol │ │ └── Token.sol │ ├── hardhat.config.ts │ ├── package-lock.json │ ├── package.json │ ├── scripts │ │ └── deploy.ts │ ├── test │ │ ├── teleport-custody.ts │ │ └── token-test.ts │ ├── tsconfig.json │ └── yarn.lock ├── flow │ ├── dao │ │ └── BloctoDAO.cdc │ ├── mining │ │ └── BloctoTokenMining.cdc │ ├── sale │ │ ├── BloctoTokenCommunitySale.cdc │ │ └── BloctoTokenPublicSale.cdc │ ├── staking │ │ └── BloctoTokenStaking.cdc │ ├── swap │ │ └── BltUsdtSwapPair.cdc │ ├── teleport │ │ ├── TeleportCustody.cdc │ │ ├── TeleportCustodyAptos.cdc │ │ ├── TeleportCustodyBSC.cdc │ │ ├── TeleportCustodyEthereum.cdc │ │ └── TeleportCustodySolana.cdc │ ├── test │ │ ├── blocto_pass_test.go │ │ ├── blocto_token_mining_test.go │ │ ├── blocto_token_staking_test.go │ │ ├── blocto_token_test.go │ │ ├── constants.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── test.go │ └── token │ │ ├── BloctoPass.cdc │ │ ├── BloctoPassStamp.cdc │ │ ├── BloctoToken.cdc │ │ ├── FUSD.cdc │ │ └── TeleportedTetherToken.cdc └── solana │ └── teleport │ ├── program │ ├── .gitignore │ ├── Cargo.toml │ ├── Xargo.toml │ ├── src │ │ ├── entrypoint.rs │ │ ├── error.rs │ │ ├── instruction.rs │ │ ├── lib.rs │ │ ├── processor.rs │ │ └── state.rs │ └── tests │ │ └── tests.rs │ └── test-owner.json ├── flow.json ├── scripts ├── dao │ └── getStakedBLT.cdc ├── general │ ├── README.md │ └── getTimestamp.cdc ├── mining │ ├── getCapMultiplier.cdc │ ├── getCriterias.cdc │ ├── getCurrentRound.cdc │ ├── getCurrentTotalReward.cdc │ ├── getMiningReward.cdc │ ├── getMiningState.cdc │ ├── getRewardCap.cdc │ ├── getRewardLockPeriod.cdc │ ├── getRewardLockRatio.cdc │ ├── getRewardsDistributed.cdc │ ├── getUnlockMiningReward.cdc │ ├── getUserRewards.cdc │ ├── getUserRewardsCollected.cdc │ └── logBloctoTokenMining.cdc ├── sale │ ├── community │ │ ├── README.md │ │ ├── getBLTVaultBalance.cdc │ │ ├── getLockupSchedule.cdc │ │ ├── getPurchaseInfo.cdc │ │ ├── getPurchasers.cdc │ │ └── gettUSDTVaultBalance.cdc │ └── public │ │ ├── README.md │ │ ├── getBLTVaultBalance.cdc │ │ ├── getPurchaseInfo.cdc │ │ ├── getPurchasers.cdc │ │ └── gettUSDTVaultBalance.cdc ├── staking │ ├── README.md │ ├── getEpoch.cdc │ ├── getEpochTokenPayout.cdc │ ├── getStakingInfo.cdc │ └── getStakingRecord.cdc ├── teleport │ ├── Aptos │ │ ├── getAllowanceAptos.cdc │ │ ├── getLockVaultBalanceAptos.cdc │ │ ├── getTeleportFeeAmountAptos.cdc │ │ └── getTeleportFeesAptos.cdc │ ├── BSC │ │ ├── getAllowanceBSC.cdc │ │ ├── getLockVaultBalanceBSC.cdc │ │ ├── getTeleportFeeAmountBSC.cdc │ │ └── getTeleportFeesBSC.cdc │ ├── Ethereum │ │ ├── getAllowanceEthereum.cdc │ │ ├── getEthereumStorage-old.cdc │ │ ├── getEthereumStorage.cdc │ │ ├── getLockVaultBalanceEthereum.cdc │ │ ├── getTeleportFeeAmountEthereum.cdc │ │ └── getTeleportFeesEthereum.cdc │ ├── README.md │ ├── Solana │ │ ├── getAllowanceSolana.cdc │ │ ├── getLockVaultBalanceSolana.cdc │ │ ├── getTeleportFeeAmountSolana.cdc │ │ └── getTeleportFeesSolana.cdc │ ├── getLockVaultBalance.cdc │ └── getTeleportLengths.cdc └── token │ ├── README.md │ ├── TeleportedTetherToken │ ├── getAllowance.cdc │ ├── getBalance.cdc │ ├── getFeeAmount.cdc │ ├── getFees.cdc │ ├── getIsFrozen.cdc │ └── getTotalSupply.cdc │ ├── checkFlowVault.cdc │ ├── getBloctoPassIds.cdc │ ├── getBloctoPassLockupAmount.cdc │ ├── getBloctoPassLockupSchedule.cdc │ ├── getBloctoPassMetadata.cdc │ ├── getBloctoPassOriginalOwner.cdc │ ├── getBloctoPassTotalBalance.cdc │ ├── getBloctoPassVaultBalance.cdc │ ├── getBloctoTokenBalance.cdc │ ├── getPredefinedLockupSchedule.cdc │ └── getTotalSupply.cdc ├── tests ├── BloctoPass_test.cdc ├── BloctoToken_test.cdc ├── CustodyBloctoTokenAptos_test.cdc ├── CustodyBloctoTokenBSC_test.cdc ├── CustodyBloctoTokenEthereum_test.cdc ├── CustodyBloctoTokenSolana_test.cdc └── TeleportedTetherToken_test.cdc └── transactions ├── dao ├── README.md ├── createProposer.cdc └── proposeNewTopic.cdc ├── general ├── addKey.cdc └── removeKey.cdc ├── mining ├── README.md ├── addDefaultCriteria.cdc ├── collectData.cdc ├── distributeReward.cdc ├── finishDistributing.cdc ├── goNextRound.cdc ├── removeCriteria.cdc ├── setupMiningReward.cdc ├── startCollecting.cdc ├── stopCollecting.cdc ├── updateCriteria.cdc ├── updateRewardCap.cdc ├── updateRewardLockPeriod.cdc ├── updateRewardLockRatio.cdc └── withdrawReward.cdc ├── sale ├── community │ ├── README.md │ ├── depositBLT.cdc │ ├── distribute.cdc │ ├── distributeBatch.cdc │ ├── freeze.cdc │ ├── purchaseBLT.cdc │ ├── refund.cdc │ ├── refundBatch.cdc │ ├── unfreeze.cdc │ ├── updateLockupScheduleId.cdc │ └── withdrawTusdt.cdc └── public │ ├── README.md │ ├── addPublicKey.cdc │ ├── depositBLT.cdc │ ├── distribute.cdc │ ├── distributeBatch.cdc │ ├── distributeBatchFull.cdc │ ├── freeze.cdc │ ├── purchaseBLT.cdc │ ├── refund.cdc │ ├── refundBatch.cdc │ ├── unfreeze.cdc │ ├── withdrawBLT.cdc │ └── withdrawTusdt.cdc ├── staking ├── README copy.md ├── README.md ├── app │ ├── ClaimRewardBlt.cdc │ ├── ClaimUnstakedBlt.cdc │ ├── EnableBltStake.cdc │ ├── RequestToUnstakeBlt.cdc │ ├── StakeNewBlt.cdc │ └── StakeUnstakedBlt.cdc ├── setEpoch.cdc ├── setEpochTokenPayout.cdc ├── setupStakingAdmin.cdc ├── stakeNewTokens.cdc ├── stakeNewTokensFromBloctoPass.cdc └── switchEpoch.cdc ├── swap ├── README.md ├── addLiquidityByAdmin.cdc ├── freeze.cdc ├── setupSwapProxy.cdc └── unfreeze.cdc ├── teleport ├── Aptos │ ├── collectFeeAptos.cdc │ ├── createTeleportAdminAptos.cdc │ ├── depositAllowanceAptos.cdc │ ├── lockTokensAptos.cdc │ ├── transferTeleportFeesAptos.cdc │ ├── unlockTokensAptos.cdc │ └── updateTeleportFeesAptos.cdc ├── BSC │ ├── collectFeeBSC.cdc │ ├── createTeleportAdminBSC.cdc │ ├── depositAllowanceBSC.cdc │ ├── lockTokensBSC.cdc │ ├── transferTeleportFeesBSC.cdc │ ├── unlockTokensBSC.cdc │ └── updateTeleportFeesBSC.cdc ├── Ethereum │ ├── collectFeeEthereum.cdc │ ├── createTeleportAdminEthereum.cdc │ ├── depositAllowanceEthereum.cdc │ ├── lockTokensEthereum.cdc │ ├── storageTestForMigration-old.cdc │ ├── storageTestForMigration.cdc │ ├── transferTeleportFeesEthereum.cdc │ ├── unlockTokensEthereum.cdc │ └── updateTeleportFeesEthereum.cdc ├── README.md ├── Solana │ ├── collectFeeSolana.cdc │ ├── createTeleportAdminSolana.cdc │ ├── depositAllowanceSolana.cdc │ ├── lockTokensSolana.cdc │ ├── transferTeleportFeesSolana.cdc │ ├── unlockTokensSolana.cdc │ └── updateTeleportFeesSolana.cdc ├── burnTokensSolana.cdc ├── lockTokens.cdc └── unlockTokens.cdc └── token ├── README.md ├── TeleportedTetherToken ├── depositAllowance.cdc ├── setupFreeze.cdc ├── setupTeleportAdmin.cdc ├── setupTokenVault.cdc ├── teleportIn.cdc ├── teleportOut.cdc ├── transfer.cdc ├── updateFees.cdc └── withdrawFee.cdc ├── admin ├── README.md ├── destroyBloctoTokenMinter.cdc ├── mintBloctoPass.cdc ├── mintBloctoPassForFounders.cdc ├── mintBloctoPassForPrivateSale.cdc ├── mintBloctoPassForTeam.cdc ├── mintBloctoPassWithCustomLockup.cdc ├── mintBloctoPassWithCustomLockupNew.cdc ├── mintBloctoPassWithPredefinedLockup.cdc ├── setupBloctoPassMinterPublic.cdc ├── setupBloctoTokenMinter.cdc ├── setupBloctoTokenMinterForMining.cdc ├── setupBloctoTokenMinterForStaking.cdc ├── setupBloctoTokenMinterForStakingSelf.cdc ├── setupCommunitySaleSchedule.cdc ├── setupFounderSchedule.cdc ├── setupPrivateSaleSchedule.cdc └── setupTeamSchedule.cdc ├── setupBloctoPassCollection.cdc ├── setupBloctoTokenVault.cdc ├── setupFUSDVault.cdc ├── transferBloctoToken.cdc ├── transferBloctoTokenBatch.cdc ├── transferBloctoTokenIntoPass.cdc ├── transferFUSDBatch.cdc └── withdrawAllFromBloctoPass.cdc /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | jobs: 3 | test_flow_contracts: 4 | docker: 5 | - image: circleci/golang:1.15 6 | 7 | environment: 8 | TEST_RESULTS: /tmp/test-results 9 | 10 | steps: 11 | - checkout 12 | - run: mkdir -p $TEST_RESULTS 13 | 14 | - restore_cache: 15 | key: go-mod-v4-{{ checksum "contracts/flow/test/go.sum" }} 16 | 17 | - run: 18 | name: Run unit tests 19 | command: | 20 | cd ./contracts/flow/test 21 | gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml 22 | 23 | - save_cache: 24 | key: go-mod-v4-{{ checksum "contracts/flow/test/go.sum" }} 25 | paths: 26 | - "/go/pkg/mod" 27 | 28 | - store_artifacts: 29 | path: /tmp/test-results 30 | destination: raw-test-output 31 | 32 | - store_test_results: 33 | path: /tmp/test-results 34 | 35 | workflows: 36 | test_flow_contracts: 37 | jobs: 38 | - test_flow_contracts -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | arguments/ 2 | build/ 3 | flowdb/ 4 | imports/ 5 | 6 | .idea 7 | .aptos 8 | .vscode 9 | flow.mainnet.json 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blocto Token Contracts 2 | 3 | ## Setup Flow CLI 4 | https://docs.onflow.org/flow-cli/install 5 | 6 | ## Run Scripts/Transactions - Examples 7 | ### Setup Blocto Token Vault 8 | ``` 9 | flow transactions send ./transactions/token/setupBloctoTokenVault.cdc \ 10 | --network testnet \ 11 | --signer blt-user-testnet \ 12 | --gas-limit 1000 13 | ``` 14 | 15 | ### Transfer Blocto Token 16 | ``` 17 | flow transactions send ./transactions/token/transferBloctoToken.cdc \ 18 | --network testnet \ 19 | --arg UFix64:100.0 \ 20 | --arg Address:0x03d1e02a48354e2b \ 21 | --signer blt-admin-testnet \ 22 | --gas-limit 1000 23 | ``` 24 | 25 | ### Setup BloctoPass Collection 26 | ``` 27 | flow transactions send ./transactions/token/setupBloctoPassCollection.cdc \ 28 | --network testnet \ 29 | --signer blt-user-testnet \ 30 | --gas-limit 1000 31 | ``` 32 | 33 | ### Mint BloctoPass NFT 34 | ``` 35 | flow transactions send ./transactions/token/mintBloctoPass.cdc \ 36 | --network testnet \ 37 | --signer blt-admin-testnet \ 38 | --gas-limit 1000 39 | ``` 40 | 41 | ### Get Blocto Token Balance 42 | ``` 43 | flow scripts execute ./scripts/token/getBloctoTokenBalance.cdc \ 44 | --network testnet \ 45 | --arg Address:0x03d1e02a48354e2b 46 | ``` 47 | 48 | ### Stake BLT into BloctoPass 49 | ``` 50 | flow transactions send ./transactions/staking/stakeNewTokens.cdc \ 51 | --network testnet \ 52 | --arg UFix64:1000.0 \ 53 | --signer blt-user-testnet \ 54 | --gas-limit 1000 55 | ``` 56 | 57 | ### Get Staking Info 58 | ``` 59 | flow scripts execute ./scripts/staking/getStakingInfo.cdc \ 60 | --network testnet \ 61 | --arg Address:0x03d1e02a48354e2b 62 | ``` 63 | 64 | ### Switch Epoch 65 | ``` 66 | flow transactions send ./transactions/staking/switchEpoch.cdc \ 67 | --network testnet \ 68 | --signer blt-admin-testnet \ 69 | --gas-limit 1000 70 | ``` 71 | -------------------------------------------------------------------------------- /contracts/ethereum/.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | 3 | # Hardhat files 4 | cache 5 | artifacts 6 | 7 | # Private files 8 | hardhat.config.secret.ts 9 | -------------------------------------------------------------------------------- /contracts/ethereum/README.md: -------------------------------------------------------------------------------- 1 | # Ethereum / BSC Side of BloctoToken and TeleportCustody 2 | 3 | ## Deployed 4 | 5 | ### BSC 6 | - BloctoToken: [0x02Bdf640fba368E7Ba5c6429cCaF251512273865](https://bscscan.com/address/0x02Bdf640fba368E7Ba5c6429cCaF251512273865) 7 | - TeleportCustody: [0x567f7048785fcEF7944B1C980AcbB32d0CA573B7](https://bscscan.com/address/0x567f7048785fcEF7944B1C980AcbB32d0CA573B7) 8 | 9 | ## Test 10 | 11 | ```sh 12 | npm run test 13 | ``` 14 | 15 | ## Deploy 16 | 17 | ### Local 18 | 19 | ```sh 20 | npm run emulator 21 | npm run deploy-local 22 | ``` 23 | 24 | ### Rinkeby 25 | 26 | 1. Set up url and deploy account in hardhat.config.ts 27 | 28 | ```js 29 | ... 30 | 31 | networks: { 32 | rinkeby: { 33 | url: "", // rinkeby url 34 | accounts: [/* private key here. 0x... */], 35 | }, 36 | }, 37 | 38 | ... 39 | ``` 40 | 41 | 2. run command 42 | 43 | ```sh 44 | npm run deploy-rinkeby 45 | ``` 46 | 47 | ## Verify 48 | 49 | ### Rinkeby 50 | 51 | 1. set up etherscan api key in `hardhat.config.ts` 52 | 53 | ``` 54 | etherscan: { 55 | apiKey: "", // etherscan api key here... 56 | }, 57 | ``` 58 | 59 | 2. verify token 60 | 61 | ```js 62 | npx hardhat verify --network rinkeby TOKEN_ADDRESS "BloctoToken" "BLT" 8 63 | ``` 64 | 65 | 3. verify teleportCustody 66 | 67 | ```js 68 | npx hardhat verify --network rinkeby TELEPORT_CUSTODY_ADDRESS "TOKEN_ADDRESS" 69 | ``` -------------------------------------------------------------------------------- /contracts/ethereum/contracts/Token.sol: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | pragma solidity 0.8.7; 3 | 4 | import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; 5 | import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; 6 | import "@openzeppelin/contracts/access/AccessControl.sol"; 7 | 8 | contract Token is ERC20, ERC20Burnable, AccessControl { 9 | uint8 private immutable _decimals; 10 | bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); 11 | 12 | constructor( 13 | string memory name, 14 | string memory symbol, 15 | uint8 decimals_ 16 | ) ERC20(name, symbol) { 17 | _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); 18 | _setupRole(MINTER_ROLE, msg.sender); 19 | 20 | _decimals = decimals_; 21 | } 22 | 23 | function mint(address to, uint256 amount) public { 24 | require(hasRole(MINTER_ROLE, msg.sender)); 25 | _mint(to, amount); 26 | } 27 | 28 | function decimals() public view virtual override returns (uint8) { 29 | return _decimals; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /contracts/ethereum/hardhat.config.ts: -------------------------------------------------------------------------------- 1 | import { HardhatUserConfig } from "hardhat/config"; 2 | import "@nomiclabs/hardhat-waffle"; 3 | import "@nomiclabs/hardhat-ethers"; 4 | import "@nomiclabs/hardhat-etherscan"; 5 | 6 | const config: HardhatUserConfig = { 7 | networks: { 8 | rinkeby: { 9 | url: "", // rinkeby url 10 | accounts: [/* private key here. 0x... */], 11 | }, 12 | bscTestnet: { 13 | url: "https://data-seed-prebsc-1-s1.binance.org:8545", 14 | accounts: [], 15 | }, 16 | bscMainnet: { 17 | url: "https://bsc-dataseed1.binance.org", 18 | accounts: [], 19 | }, 20 | }, 21 | solidity: { 22 | compilers: [ 23 | { 24 | version: "0.8.7", 25 | settings: { 26 | optimizer: { enabled: true, runs: 1000 }, 27 | }, 28 | }, 29 | ], 30 | }, 31 | etherscan: { 32 | apiKey: "", // etherscan api key here... 33 | }, 34 | }; 35 | 36 | export default config; 37 | -------------------------------------------------------------------------------- /contracts/ethereum/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardhat-project", 3 | "scripts": { 4 | "clean-build": "hardhat clean && hardhat compile", 5 | "build": "hardhat compile", 6 | "test": "hardhat test", 7 | "emulator": "hardhat node", 8 | "deploy-local": "hardhat run --network localhost scripts/deploy.ts", 9 | "deploy-rinkeby": "hardhat run --network rinkeby scripts/deploy.ts", 10 | "deploy-bsc-testnet": "hardhat run --network bscTestnet scripts/deploy.ts", 11 | "deploy-bsc-mainnet": "hardhat run --network bscMainnet scripts/deploy.ts" 12 | }, 13 | "devDependencies": { 14 | "@nomiclabs/hardhat-ethers": "^2.0.2", 15 | "@nomiclabs/hardhat-etherscan": "^2.1.3", 16 | "@nomiclabs/hardhat-waffle": "^2.0.1", 17 | "@types/chai": "^4.2.18", 18 | "@types/mocha": "^8.2.2", 19 | "@types/node": "^15.12.2", 20 | "chai": "^4.3.4", 21 | "ethereum-waffle": "^3.4.0", 22 | "ethers": "^5.3.1", 23 | "hardhat": "^2.4.0", 24 | "ts-node": "^10.0.0", 25 | "typescript": "^4.3.4" 26 | }, 27 | "dependencies": { 28 | "@openzeppelin/contracts": "^4.1.0" 29 | } 30 | } -------------------------------------------------------------------------------- /contracts/ethereum/scripts/deploy.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "hardhat"; 2 | 3 | async function main() { 4 | const Token = await ethers.getContractFactory("Token"); 5 | const token = await Token.deploy("BloctoToken", "BLT", 8); 6 | await token.deployed(); 7 | console.log(`token address: ${token.address}`); 8 | 9 | const TeleportCustody = await ethers.getContractFactory("TeleportCustody"); 10 | const teleportCustody = await TeleportCustody.deploy(token.address); 11 | await teleportCustody.deployed(); 12 | console.log(`teleport address: ${teleportCustody.address}`); 13 | 14 | const accounts = await ethers.getSigners(); 15 | let tx = await token.connect(accounts[0]).grantRole(token.MINTER_ROLE(), teleportCustody.address); 16 | console.log(`add minter auth for teleport contract, txhash: ${tx.hash}`); 17 | } 18 | 19 | main() 20 | .then(() => process.exit(0)) 21 | .catch((error) => { 22 | console.error(error); 23 | process.exit(1); 24 | }); 25 | -------------------------------------------------------------------------------- /contracts/ethereum/test/token-test.ts: -------------------------------------------------------------------------------- 1 | import { ethers } from "hardhat"; 2 | import { Signer, Contract } from "ethers"; 3 | import { solidity } from "ethereum-waffle"; 4 | import { use, expect } from "chai"; 5 | 6 | use(solidity); 7 | 8 | describe("Token", function () { 9 | let accounts: Signer[]; 10 | let token: Contract; 11 | 12 | beforeEach(async function () { 13 | accounts = await ethers.getSigners(); 14 | const Token = await ethers.getContractFactory("Token"); 15 | token = await Token.deploy("token", "BLT", 8); 16 | }); 17 | 18 | it("init supply should be 0", async function () { 19 | expect(await token.totalSupply()).to.equal(0); 20 | }); 21 | 22 | it("token decimals", async function () { 23 | expect(await token.decimals()).to.equal(8); 24 | }); 25 | 26 | it("mint by owner", async function () { 27 | await expect(() => token.connect(accounts[0]).mint(accounts[1].getAddress(), 100)).to.changeTokenBalance( 28 | token, 29 | accounts[1], 30 | 100 31 | ); 32 | }); 33 | 34 | it("mint by allowed role", async function () { 35 | await token.connect(accounts[0]).grantRole(token.MINTER_ROLE(), accounts[1].getAddress()); 36 | await expect(() => token.connect(accounts[1]).mint(accounts[2].getAddress(), 100)).to.changeTokenBalance( 37 | token, 38 | accounts[2], 39 | 100 40 | ); 41 | }); 42 | 43 | it("mint by unknown", async function () { 44 | await expect(token.connect(accounts[1]).mint(accounts[2].getAddress(), 100)).to.be.reverted; 45 | }); 46 | 47 | it("burn by user", async function () { 48 | await token.connect(accounts[0]).mint(accounts[1].getAddress(), 100); 49 | await expect(() => token.connect(accounts[1]).burn(100)).to.changeTokenBalance(token, accounts[1], -100); 50 | }); 51 | 52 | it("burn by owner", async function () { 53 | await token.connect(accounts[0]).mint(accounts[1].getAddress(), 100); 54 | await token.connect(accounts[1]).approve(accounts[0].getAddress(), 100); 55 | await expect(() => token.connect(accounts[0]).burnFrom(accounts[1].getAddress(), 100)).to.changeTokenBalance( 56 | token, 57 | accounts[1], 58 | -100 59 | ); 60 | }); 61 | }); 62 | -------------------------------------------------------------------------------- /contracts/ethereum/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES2017", 4 | "module": "commonjs", 5 | "declaration": true, 6 | "declarationMap": true, 7 | "sourceMap": true, 8 | "outDir": "./dist", 9 | "strict": true, 10 | "rootDirs": [ 11 | "./src", 12 | "./test" 13 | ], 14 | "esModuleInterop": true 15 | }, 16 | "exclude": [ 17 | "dist", 18 | "node_modules" 19 | ], 20 | "include": [ 21 | "./test", 22 | "./src" 23 | ] 24 | } -------------------------------------------------------------------------------- /contracts/flow/test/blocto_token_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | 7 | "github.com/onflow/cadence" 8 | emulator "github.com/onflow/flow-emulator" 9 | "github.com/onflow/flow-go-sdk" 10 | "github.com/onflow/flow-go-sdk/crypto" 11 | "github.com/onflow/flow-go-sdk/templates" 12 | "github.com/onflow/flow-go-sdk/test" 13 | "github.com/stretchr/testify/assert" 14 | 15 | ft_contracts "github.com/onflow/flow-ft/lib/go/contracts" 16 | ) 17 | 18 | const ( 19 | btSetupBloctoTokenMinterForStakingPath = projectRootPath + "/transactions/token/admin/setupBloctoTokenMinterForStaking.cdc" 20 | ) 21 | 22 | func BloctoTokenDeployContract(b *emulator.Blockchain, t *testing.T) (flow.Address, flow.Address, crypto.Signer) { 23 | accountKeys := test.AccountKeyGenerator() 24 | 25 | // Should be able to deploy a contract as a new account with no keys. 26 | fungibleTokenCode := loadFungibleToken() 27 | fungibleAddr, err := b.CreateAccount( 28 | []*flow.AccountKey{}, 29 | []templates.Contract{{ 30 | Name: "FungibleToken", 31 | Source: string(fungibleTokenCode), 32 | }}, 33 | ) 34 | assert.NoError(t, err) 35 | 36 | _, err = b.CommitBlock() 37 | assert.NoError(t, err) 38 | 39 | bloctoTokenAccountKey, bloctoTokenSigner := accountKeys.NewWithSigner() 40 | bloctoTokenCode := loadBloctoToken(fungibleAddr) 41 | 42 | bloctoTokenAddr, err := b.CreateAccount( 43 | []*flow.AccountKey{bloctoTokenAccountKey}, 44 | []templates.Contract{{ 45 | Name: "BloctoToken", 46 | Source: string(bloctoTokenCode), 47 | }}, 48 | ) 49 | assert.NoError(t, err) 50 | 51 | _, err = b.CommitBlock() 52 | assert.NoError(t, err) 53 | 54 | return fungibleAddr, bloctoTokenAddr, bloctoTokenSigner 55 | } 56 | 57 | func loadFungibleToken() []byte { 58 | return ft_contracts.FungibleToken() 59 | } 60 | 61 | func loadBloctoToken(fungibleAddr flow.Address) []byte { 62 | return []byte(strings.ReplaceAll( 63 | string(readFile(bloctoTokenPath)), 64 | "\"./FungibleToken.cdc\"", 65 | "0x"+fungibleAddr.String(), 66 | )) 67 | } 68 | 69 | func btSetupBloctoTokenMinterForStakingTransaction(btAddr flow.Address, ftAddr flow.Address) []byte { 70 | code := string(readFile(btSetupBloctoTokenMinterForStakingPath)) 71 | 72 | code = strings.ReplaceAll(code, "\"../../../contracts/flow/token/FungibleToken.cdc\"", "0x"+ftAddr.String()) 73 | code = strings.ReplaceAll(code, "\"../../../contracts/flow/token/BloctoToken.cdc\"", "0x"+btAddr.String()) 74 | 75 | return []byte(code) 76 | } 77 | 78 | func SetupBloctoTokenMinterForStaking( 79 | t *testing.T, b *emulator.Blockchain, 80 | ftAddr flow.Address, amount cadence.Value, 81 | btAddr flow.Address, btSigner crypto.Signer, 82 | minterAddr flow.Address, minterSigner crypto.Signer) { 83 | 84 | tx := flow.NewTransaction(). 85 | SetScript(btSetupBloctoTokenMinterForStakingTransaction(btAddr, ftAddr)). 86 | SetGasLimit(100). 87 | SetProposalKey(b.ServiceKey().Address, b.ServiceKey().Index, b.ServiceKey().SequenceNumber). 88 | SetPayer(b.ServiceKey().Address). 89 | AddAuthorizer(btAddr). 90 | AddAuthorizer(minterAddr) 91 | 92 | _ = tx.AddArgument(amount) 93 | 94 | signAndSubmit( 95 | t, b, tx, 96 | []flow.Address{b.ServiceKey().Address, btAddr, minterAddr}, 97 | []crypto.Signer{b.ServiceKey().Signer(), btSigner, minterSigner}, 98 | false, 99 | ) 100 | } 101 | -------------------------------------------------------------------------------- /contracts/flow/test/constants.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | const ( 4 | projectRootPath = "../../.." 5 | bloctoTokenMiningPath = projectRootPath + "/contracts/flow/mining/BloctoTokenMining.cdc" 6 | bloctoTokenStakingPath = projectRootPath + "/contracts/flow/staking/BloctoTokenStaking.cdc" 7 | bloctoTokenPath = projectRootPath + "/contracts/flow/token/BloctoToken.cdc" 8 | bloctoPassPath = projectRootPath + "/contracts/flow/token/BloctoPass.cdc" 9 | bloctoPassStampPath = projectRootPath + "/contracts/flow/token/BloctoPassStamp.cdc" 10 | ) 11 | -------------------------------------------------------------------------------- /contracts/flow/test/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/portto/blt-contracts/contracts/flow/test 2 | 3 | go 1.15 4 | 5 | require ( 6 | github.com/onflow/cadence v0.23.0 7 | github.com/onflow/flow-emulator v0.29.0 8 | github.com/onflow/flow-ft/lib/go/contracts v0.5.0 9 | github.com/onflow/flow-go v0.23.2-0.20220304145234-bf10d55c40fa 10 | github.com/onflow/flow-go-sdk v0.24.0 11 | github.com/onflow/flow-nft/lib/go/contracts v0.0.0-20210915191154-12ee8c507a0e 12 | github.com/stretchr/testify v1.7.1 13 | ) 14 | -------------------------------------------------------------------------------- /contracts/solana/teleport/program/.gitignore: -------------------------------------------------------------------------------- 1 | # Generated by Cargo 2 | # will have compiled files and executables 3 | /target/ 4 | 5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries 6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html 7 | Cargo.lock 8 | 9 | # These are backup files generated by rustfmt 10 | **/*.rs.bk -------------------------------------------------------------------------------- /contracts/solana/teleport/program/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["yihau "] 3 | edition = "2018" 4 | name = "blt_teleport" 5 | version = "0.1.0" 6 | 7 | [features] 8 | no-entrypoint = [] 9 | test-bpf = [] 10 | 11 | [dependencies] 12 | borsh = "0.9.1" 13 | num-derive = "0.3" 14 | num-traits = "0.2" 15 | solana-program = "1.7.11" 16 | spl-token = {version = "3.1.1", features = ["no-entrypoint"]} 17 | thiserror = "1.0" 18 | uint = "0.8" 19 | 20 | [dev-dependencies] 21 | solana-program-test = "1.7.11" 22 | solana-sdk = "1.7.11" 23 | 24 | [lib] 25 | crate-type = ["cdylib", "lib"] 26 | -------------------------------------------------------------------------------- /contracts/solana/teleport/program/Xargo.toml: -------------------------------------------------------------------------------- 1 | [target.bpfel-unknown-unknown.dependencies.std] 2 | features = [] -------------------------------------------------------------------------------- /contracts/solana/teleport/program/src/entrypoint.rs: -------------------------------------------------------------------------------- 1 | //! Program entrypoint definitions 2 | 3 | #![cfg(all(target_arch = "bpf", not(feature = "no-entrypoint")))] 4 | 5 | use { 6 | crate::{error::TeleportError, processor}, 7 | solana_program::{ 8 | account_info::AccountInfo, entrypoint, entrypoint::ProgramResult, 9 | program_error::PrintProgramError, pubkey::Pubkey, 10 | }, 11 | }; 12 | 13 | entrypoint!(process_instruction); 14 | fn process_instruction( 15 | program_id: &Pubkey, 16 | accounts: &[AccountInfo], 17 | instruction_data: &[u8], 18 | ) -> ProgramResult { 19 | if let Err(error) = 20 | processor::Processor::process_instruction(program_id, accounts, instruction_data) 21 | { 22 | // catch the error so we can print it 23 | error.print::(); 24 | return Err(error); 25 | } 26 | Ok(()) 27 | } 28 | -------------------------------------------------------------------------------- /contracts/solana/teleport/program/src/error.rs: -------------------------------------------------------------------------------- 1 | //! Error types 2 | 3 | use { 4 | num_derive::FromPrimitive, 5 | num_traits::FromPrimitive, 6 | solana_program::{ 7 | decode_error::DecodeError, msg, program_error::PrintProgramError, 8 | program_error::ProgramError, 9 | }, 10 | thiserror::Error, 11 | }; 12 | 13 | #[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)] 14 | pub enum TeleportError { 15 | #[error("AuthFailed")] 16 | AuthFailed, 17 | #[error("UninitializedAccount")] 18 | UninitializedAccount, 19 | #[error("AlreadyInUse")] 20 | AlreadyInUse, 21 | #[error("NotRentExempt")] 22 | NotRentExempt, 23 | #[error("MissingRequiredSignature")] 24 | MissingRequiredSignature, 25 | #[error("IncorrectProgramAccount")] 26 | IncorrectProgramAccount, 27 | #[error("Freeze")] 28 | Freeze, 29 | #[error("UnexpectedError")] 30 | UnexpectedError, 31 | } 32 | 33 | impl From for ProgramError { 34 | fn from(e: TeleportError) -> Self { 35 | ProgramError::Custom(e as u32) 36 | } 37 | } 38 | 39 | impl DecodeError for TeleportError { 40 | fn type_of() -> &'static str { 41 | "Teleport Error" 42 | } 43 | } 44 | 45 | impl PrintProgramError for TeleportError { 46 | fn print(&self) 47 | where 48 | E: 'static + std::error::Error + DecodeError + PrintProgramError + FromPrimitive, 49 | { 50 | match self { 51 | TeleportError::AuthFailed => msg!("Auth Failed"), 52 | TeleportError::UninitializedAccount => msg!("Uninitialized Account"), 53 | TeleportError::AlreadyInUse => msg!("Already In Use"), 54 | TeleportError::NotRentExempt => msg!("Not Rent Exempt"), 55 | TeleportError::MissingRequiredSignature => msg!("Missing Required Signature"), 56 | TeleportError::IncorrectProgramAccount => msg!("Incorrect Program Account"), 57 | TeleportError::Freeze => msg!("Freeze"), 58 | TeleportError::UnexpectedError => msg!("Unexpected Error"), 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /contracts/solana/teleport/program/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod error; 2 | pub mod instruction; 3 | pub mod processor; 4 | pub mod state; 5 | 6 | #[cfg(not(feature = "no-entrypoint"))] 7 | mod entrypoint; 8 | 9 | // Export current sdk types for downstream users building with a different sdk version 10 | pub use solana_program; 11 | 12 | // program id 13 | solana_program::declare_id!("BLT2FgFauegpkQPXmT9dSKtHevX1dDNPgj4KtKFiDbPq"); 14 | -------------------------------------------------------------------------------- /contracts/solana/teleport/program/src/state.rs: -------------------------------------------------------------------------------- 1 | //! State transition types 2 | 3 | use { 4 | crate::error::TeleportError, 5 | borsh::{BorshDeserialize, BorshSerialize}, 6 | solana_program::{msg, program_error::ProgramError, pubkey::Pubkey}, 7 | }; 8 | 9 | // TODO use env! 10 | pub const OWNER_KEY: &str = "Ad8pZMQCznufvH85mVhyUyuchhEvBRMMMSawJTPCBVZq"; 11 | 12 | // TODO use env! 13 | pub const MULTISIG_PROGRAM_KEY: &str = "D6vhDDD47LqHfHGps5YKkzJNBhXasrTf5LbNmkF3XHww"; 14 | 15 | // TODO use env! 16 | pub const BLT_MINT_KEY: &str = "BLT1noyNr3GttckEVrtcfC6oyK6yV1DpPgSyXbncMwef"; 17 | 18 | pub const SIGNER_SEED: &[u8] = b"BLT"; 19 | 20 | pub const MAX_ADMIN: usize = 5; 21 | 22 | /// Program states. 23 | #[repr(C)] 24 | #[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)] 25 | pub struct Config { 26 | pub is_init: bool, 27 | pub is_frozen: bool, 28 | pub admins: [Pubkey; MAX_ADMIN], 29 | } 30 | 31 | impl Config { 32 | pub const LEN: usize = 162; 33 | 34 | pub fn add_admin(&mut self, add_admin_key: &Pubkey) -> Result<(), ProgramError> { 35 | for admin in &mut self.admins { 36 | if admin == &mut Pubkey::default() { 37 | *admin = *add_admin_key; 38 | return Ok(()); 39 | } 40 | } 41 | msg!("admin list is full"); 42 | Err(TeleportError::UnexpectedError.into()) 43 | } 44 | 45 | pub fn remove_admin(&mut self, remove_admin_key: &Pubkey) -> Result<(), ProgramError> { 46 | for admin in &mut self.admins { 47 | if admin == remove_admin_key { 48 | *admin = Pubkey::default(); 49 | return Ok(()); 50 | } 51 | } 52 | msg!("key not found"); 53 | Err(TeleportError::UnexpectedError.into()) 54 | } 55 | 56 | pub fn contain_admin(&self, target: &Pubkey) -> bool { 57 | for admin in &self.admins { 58 | if admin == target { 59 | return true; 60 | } 61 | } 62 | false 63 | } 64 | } 65 | 66 | #[repr(C)] 67 | #[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)] 68 | pub struct Admin { 69 | pub is_init: bool, 70 | pub auth: Pubkey, 71 | pub allowance: u64, 72 | } 73 | 74 | impl Admin { 75 | pub const LEN: usize = 41; 76 | } 77 | 78 | #[repr(C)] 79 | #[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug, Clone)] 80 | pub struct TeleportOutRecord { 81 | pub is_init: bool, 82 | } 83 | 84 | impl TeleportOutRecord { 85 | pub const LEN: usize = 1; 86 | } 87 | -------------------------------------------------------------------------------- /contracts/solana/teleport/test-owner.json: -------------------------------------------------------------------------------- 1 | [216,77,18,252,166,244,245,106,13,111,107,26,108,43,230,245,113,207,205,116,14,52,64,196,192,63,41,220,146,82,66,53,161,111,219,59,147,221,7,127,88,42,141,30,211,69,198,108,142,249,183,249,92,127,241,91,118,190,46,20,186,220,132,23] -------------------------------------------------------------------------------- /scripts/dao/getStakedBLT.cdc: -------------------------------------------------------------------------------- 1 | import BloctoDAO from "../../contracts/flow/dao/BloctoDAO.cdc" 2 | 3 | pub fun main(address: Address): UFix64 { 4 | return BloctoDAO.getStakedBLT(address: address) 5 | } -------------------------------------------------------------------------------- /scripts/general/README.md: -------------------------------------------------------------------------------- 1 | # General 2 | ### Get Current Network Timestamp 3 | ``` 4 | flow scripts execute ./scripts/general/getTimestamp.cdc \ 5 | --network testnet 6 | ``` 7 | -------------------------------------------------------------------------------- /scripts/general/getTimestamp.cdc: -------------------------------------------------------------------------------- 1 | pub fun main(): UFix64 { 2 | return getCurrentBlock().timestamp 3 | } 4 | -------------------------------------------------------------------------------- /scripts/mining/getCapMultiplier.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): UInt64 { 4 | return BloctoTokenMining.getCapMultiplier() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getCriterias.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): {String: BloctoTokenMining.Criterion} { 4 | return BloctoTokenMining.getCriteria() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getCurrentRound.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): UInt64 { 4 | return BloctoTokenMining.getCurrentRound() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getCurrentTotalReward.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return BloctoTokenMining.getCurrentTotalReward() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getMiningReward.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(address: Address): [BloctoTokenMining.RewardLockInfo] { 4 | let miningRewardRef = getAccount(address).getCapability(BloctoTokenMining.MiningRewardPublicPath) 5 | .borrow<&{BloctoTokenMining.MiningRewardPublic}>() 6 | ?? panic("Could not borrow mining reward public reference") 7 | 8 | return miningRewardRef.getRewardsLocked() 9 | } -------------------------------------------------------------------------------- /scripts/mining/getMiningState.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): BloctoTokenMining.MiningState { 4 | return BloctoTokenMining.getMiningState() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getRewardCap.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return BloctoTokenMining.getRewardCap() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getRewardLockPeriod.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): UInt64 { 4 | return BloctoTokenMining.getRewardLockPeriod() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getRewardLockRatio.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return BloctoTokenMining.getRewardLockRatio() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getRewardsDistributed.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): {Address: UInt64} { 4 | return BloctoTokenMining.getRewardsDistributed() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getUnlockMiningReward.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(address: Address): UFix64 { 4 | let miningRewardRef = getAccount(address).getCapability(BloctoTokenMining.MiningRewardPublicPath) 5 | .borrow<&{BloctoTokenMining.MiningRewardPublic}>() 6 | ?? panic("Could not borrow mining reward public reference") 7 | 8 | return miningRewardRef.computeUnlocked() 9 | } -------------------------------------------------------------------------------- /scripts/mining/getUserRewards.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): {Address: UFix64} { 4 | return BloctoTokenMining.getUserRewards() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/getUserRewardsCollected.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main(): {Address: UInt64} { 4 | return BloctoTokenMining.getUserRewardsCollected() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/mining/logBloctoTokenMining.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | pub fun main() { 4 | log({"miningState": BloctoTokenMining.getMiningState()}) 5 | log({"currentRound": BloctoTokenMining.getCurrentRound()}) 6 | log({"currentTotalReward": BloctoTokenMining.getCurrentTotalReward()}) 7 | log({"rewardCap": BloctoTokenMining.getRewardCap()}) 8 | log({"capMultiplier": BloctoTokenMining.getCapMultiplier()}) 9 | log({"criterias": BloctoTokenMining.getCriterias()}) 10 | log({"rewardLockPeriod": BloctoTokenMining.getRewardLockPeriod()}) 11 | log({"rewardLockRatio": BloctoTokenMining.getRewardLockRatio()}) 12 | log({"userRewardsCollected": BloctoTokenMining.getUserRewardsCollected()}) 13 | log({"userRewards": BloctoTokenMining.getUserRewards()}) 14 | log({"rewardsDistributed": BloctoTokenMining.getRewardsDistributed()}) 15 | } 16 | -------------------------------------------------------------------------------- /scripts/sale/community/README.md: -------------------------------------------------------------------------------- 1 | # Sale 2 | ### Get Lockup Schedule 3 | ``` 4 | flow scripts execute ./scripts/sale/community/getLockupSchedule.cdc \ 5 | --network testnet 6 | ``` 7 | 8 | ### Get Purchasers 9 | ``` 10 | flow scripts execute ./scripts/sale/community/getPurchasers.cdc \ 11 | --network testnet 12 | ``` 13 | 14 | ### Get Purchase Info 15 | ``` 16 | flow scripts execute ./scripts/sale/community/getPurchaseInfo.cdc \ 17 | --network testnet \ 18 | --arg Address:0x457df669b4f4d1a4 19 | ``` 20 | 21 | ### Get BLT Vault Balance 22 | ``` 23 | flow scripts execute ./scripts/sale/community/getBLTVaultBalance.cdc \ 24 | --network testnet 25 | ``` 26 | 27 | ### Get tUSDT Vault Balance 28 | ``` 29 | flow scripts execute ./scripts/sale/community/gettUSDTVaultBalance.cdc \ 30 | --network testnet 31 | ``` 32 | -------------------------------------------------------------------------------- /scripts/sale/community/getBLTVaultBalance.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return BloctoTokenSale.getBltVaultBalance() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/sale/community/getLockupSchedule.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | pub fun main(): {UFix64: UFix64} { 4 | return BloctoTokenSale.getLockupSchedule() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/sale/community/getPurchaseInfo.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | pub fun main(address: Address): BloctoTokenSale.PurchaseInfo? { 4 | return BloctoTokenSale.getPurchase(address: address) 5 | } 6 | -------------------------------------------------------------------------------- /scripts/sale/community/getPurchasers.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | pub fun main(): [Address] { 4 | return BloctoTokenSale.getPurchasers() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/sale/community/gettUSDTVaultBalance.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return BloctoTokenSale.getTusdtVaultBalance() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/sale/public/README.md: -------------------------------------------------------------------------------- 1 | # Sale 2 | ### Get Purchasers 3 | ``` 4 | flow scripts execute ./scripts/sale/public/getPurchasers.cdc \ 5 | --network testnet 6 | ``` 7 | 8 | ### Get Purchase Info 9 | ``` 10 | flow scripts execute ./scripts/sale/public/getPurchaseInfo.cdc \ 11 | --network testnet \ 12 | --arg Address:0x457df669b4f4d1a4 13 | ``` 14 | 15 | ### Get BLT Vault Balance 16 | ``` 17 | flow scripts execute ./scripts/sale/public/getBLTVaultBalance.cdc \ 18 | --network testnet 19 | ``` 20 | 21 | ### Get tUSDT Vault Balance 22 | ``` 23 | flow scripts execute ./scripts/sale/public/gettUSDTVaultBalance.cdc \ 24 | --network testnet 25 | ``` 26 | -------------------------------------------------------------------------------- /scripts/sale/public/getBLTVaultBalance.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return BloctoTokenPublicSale.getBltVaultBalance() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/sale/public/getPurchaseInfo.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | pub fun main(address: Address): BloctoTokenPublicSale.PurchaseInfo? { 4 | return BloctoTokenPublicSale.getPurchase(address: address) 5 | } 6 | -------------------------------------------------------------------------------- /scripts/sale/public/getPurchasers.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | pub fun main(): [Address] { 4 | return BloctoTokenPublicSale.getPurchasers() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/sale/public/gettUSDTVaultBalance.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return BloctoTokenPublicSale.getTusdtVaultBalance() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/staking/README.md: -------------------------------------------------------------------------------- 1 | # Staking 2 | ### Get Staking Info 3 | ``` 4 | flow scripts execute ./scripts/staking/getStakingInfo.cdc \ 5 | --network testnet \ 6 | --arg Address:0x03d1e02a48354e2b 7 | --arg Index:0 8 | ``` 9 | 10 | ### Get Epoch BLT Payout 11 | ``` 12 | flow scripts execute ./scripts/staking/getEpochTokenPayout.cdc \ 13 | --network testnet 14 | ``` 15 | -------------------------------------------------------------------------------- /scripts/staking/getEpoch.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoTokenStaking" 2 | 3 | access(all) 4 | fun main(): UInt64 { 5 | return BloctoTokenStaking.getEpoch() 6 | } 7 | -------------------------------------------------------------------------------- /scripts/staking/getEpochTokenPayout.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoTokenStaking" 2 | 3 | access(all) 4 | fun main(): UFix64 { 5 | return BloctoTokenStaking.getEpochTokenPayout() 6 | } 7 | -------------------------------------------------------------------------------- /scripts/staking/getStakingInfo.cdc: -------------------------------------------------------------------------------- 1 | import "NonFungibleToken" 2 | import "BloctoPass" 3 | import "BloctoTokenStaking" 4 | 5 | access(all) 6 | fun main(address: Address, index: Int): BloctoTokenStaking.StakerInfo { 7 | let collectionRef = getAccount(address).capabilities.borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>(/public/bloctoPassCollection) 8 | ?? panic("Could not borrow collection public reference") 9 | 10 | let ids = collectionRef.getIDs() 11 | let bloctoPass = collectionRef.borrowBloctoPassPublic(id: ids[index]) 12 | 13 | return bloctoPass.getStakingInfo() 14 | } 15 | -------------------------------------------------------------------------------- /scripts/staking/getStakingRecord.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenStaking from "../../contracts/flow/staking/BloctoTokenStaking.cdc" 2 | 3 | pub fun main(stakerID: UInt64): UFix64 { 4 | return BloctoTokenStaking.getStakerBalance(stakerID: stakerID) 5 | } 6 | -------------------------------------------------------------------------------- /scripts/teleport/Aptos/getAllowanceAptos.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyAptos" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyAptos.TeleportUser}>(TeleportCustodyAptos.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return teleportUserRef.allowedAmount 8 | } -------------------------------------------------------------------------------- /scripts/teleport/Aptos/getLockVaultBalanceAptos.cdc: -------------------------------------------------------------------------------- 1 | import TeleportCustodyAptos from "../../contracts/flow/teleport/TeleportCustodyAptos.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return TeleportCustodyAptos.getLockVaultBalance() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/teleport/Aptos/getTeleportFeeAmountAptos.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyAptos" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportUserRef = getAccount(teleportAdmin).storage.borrow<&TeleportCustodyAptos.TeleportAdmin>(TeleportCustodyAptos.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return teleportUserRef.feeCollector.balance 8 | } -------------------------------------------------------------------------------- /scripts/teleport/Aptos/getTeleportFeesAptos.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyAptos" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): [UFix64] { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyAptos.TeleportUser}>(TeleportCustodyAptos.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return [teleportUserRef.lockFee, teleportUserRef.unlockFee] 8 | } -------------------------------------------------------------------------------- /scripts/teleport/BSC/getAllowanceBSC.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyBSC" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyBSC.TeleportUser}>(TeleportCustodyBSC.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return teleportUserRef.allowedAmount 8 | } -------------------------------------------------------------------------------- /scripts/teleport/BSC/getLockVaultBalanceBSC.cdc: -------------------------------------------------------------------------------- 1 | import TeleportCustodyBSC from "../../contracts/flow/teleport/TeleportCustodyBSC.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return TeleportCustodyBSC.getLockVaultBalance() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/teleport/BSC/getTeleportFeeAmountBSC.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyBSC" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportUserRef = getAccount(teleportAdmin).storage.borrow<&TeleportCustodyBSC.TeleportAdmin>(TeleportCustodyBSC.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return teleportUserRef.feeCollector.balance 8 | } -------------------------------------------------------------------------------- /scripts/teleport/BSC/getTeleportFeesBSC.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyBSC" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): [UFix64] { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyBSC.TeleportUser}>(TeleportCustodyBSC.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return [teleportUserRef.lockFee, teleportUserRef.unlockFee] 8 | } -------------------------------------------------------------------------------- /scripts/teleport/Ethereum/getAllowanceEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyEthereum" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyEthereum.TeleportUser}>(TeleportCustodyEthereum.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return teleportUserRef.allowedAmount 8 | } -------------------------------------------------------------------------------- /scripts/teleport/Ethereum/getEthereumStorage-old.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyEthereum" 2 | import "BloctoToken" 3 | import "FungibleToken" 4 | 5 | pub fun main(teleportAdmin: Address, user: Address): [UFix64] { 6 | let teleportUserRef = getAccount(teleportAdmin).getCapability<&{TeleportCustodyEthereum.TeleportUser}>(TeleportCustodyEthereum.TeleportAdminTeleportUserPath).borrow() 7 | ?? panic("Could not borrow a reference to TeleportUser") 8 | 9 | let userRef = getAccount(user).getCapability<&{FungibleToken.Balance}>(BloctoToken.TokenPublicBalancePath).borrow() 10 | ?? panic("Could not borrow a reference to the vault resource") 11 | 12 | return [teleportUserRef.allowedAmount, userRef.balance] 13 | } -------------------------------------------------------------------------------- /scripts/teleport/Ethereum/getEthereumStorage.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyEthereum" 2 | import "BloctoToken" 3 | import "FungibleToken" 4 | 5 | access(all) 6 | fun main(teleportAdmin: Address, user: Address): [UFix64] { 7 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyEthereum.TeleportUser}>(TeleportCustodyEthereum.TeleportAdminTeleportUserPath) 8 | ?? panic("Could not borrow a reference to TeleportUser") 9 | 10 | let userRef = getAccount(user).capabilities.borrow<&{FungibleToken.Balance}>(BloctoToken.TokenPublicBalancePath) 11 | ?? panic("Could not borrow a reference to the vault resource") 12 | 13 | return [teleportUserRef.allowedAmount, userRef.balance] 14 | } -------------------------------------------------------------------------------- /scripts/teleport/Ethereum/getLockVaultBalanceEthereum.cdc: -------------------------------------------------------------------------------- 1 | import TeleportCustodyEthereum from "../../contracts/flow/teleport/TeleportCustodyEthereum.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return TeleportCustodyEthereum.getLockVaultBalance() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/teleport/Ethereum/getTeleportFeeAmountEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyEthereum" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportUserRef = getAccount(teleportAdmin).storage.borrow<&TeleportCustodyEthereum.TeleportAdmin>(TeleportCustodyEthereum.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return teleportUserRef.feeCollector.balance 8 | } -------------------------------------------------------------------------------- /scripts/teleport/Ethereum/getTeleportFeesEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyEthereum" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): [UFix64] { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyEthereum.TeleportUser}>(TeleportCustodyEthereum.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return [teleportUserRef.lockFee, teleportUserRef.unlockFee] 8 | } -------------------------------------------------------------------------------- /scripts/teleport/README.md: -------------------------------------------------------------------------------- 1 | # Teleport 2 | ### Get Teleport Custody Lock Balance 3 | ``` 4 | flow scripts execute ./scripts/teleport/getLockVaultBalance.cdc \ 5 | --network testnet 6 | ``` 7 | 8 | ### Get Teleport Custody Lock Balance (BSC) 9 | ``` 10 | flow scripts execute ./scripts/teleport/getLockVaultBalanceBSC.cdc \ 11 | --network mainnet 12 | ``` 13 | 14 | ### Get Teleport Address and TxHash Length 15 | ``` 16 | flow scripts execute ./scripts/teleport/getTeleportLengths.cdc \ 17 | --network testnet 18 | ``` 19 | -------------------------------------------------------------------------------- /scripts/teleport/Solana/getAllowanceSolana.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodySolana" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodySolana.TeleportUser}>(TeleportCustodySolana.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return teleportUserRef.allowedAmount 8 | } -------------------------------------------------------------------------------- /scripts/teleport/Solana/getLockVaultBalanceSolana.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodySolana" 2 | 3 | pub fun main(): UFix64 { 4 | return TeleportCustodySolana.getLockVaultBalance() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/teleport/Solana/getTeleportFeeAmountSolana.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodySolana" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportUserRef = getAccount(teleportAdmin).storage.borrow<&TeleportCustodySolana.TeleportAdmin>(TeleportCustodySolana.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return teleportUserRef.feeCollector.balance 8 | } -------------------------------------------------------------------------------- /scripts/teleport/Solana/getTeleportFeesSolana.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodySolana" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): [UFix64] { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodySolana.TeleportUser}>(TeleportCustodySolana.TeleportAdminTeleportUserPath) 6 | ?? panic("Could not borrow a reference to TeleportUser") 7 | return [teleportUserRef.lockFee, teleportUserRef.unlockFee] 8 | } -------------------------------------------------------------------------------- /scripts/teleport/getLockVaultBalance.cdc: -------------------------------------------------------------------------------- 1 | import TeleportCustody from "../../contracts/flow/teleport/TeleportCustody.cdc" 2 | 3 | pub fun main(): UFix64 { 4 | return TeleportCustody.getLockVaultBalance() 5 | } 6 | -------------------------------------------------------------------------------- /scripts/teleport/getTeleportLengths.cdc: -------------------------------------------------------------------------------- 1 | import TeleportCustody from "../../contracts/flow/teleport/TeleportCustody.cdc" 2 | 3 | pub fun main(): [Int] { 4 | return [TeleportCustody.teleportAddressLength, TeleportCustody.teleportTxHashLength] 5 | } 6 | -------------------------------------------------------------------------------- /scripts/token/README.md: -------------------------------------------------------------------------------- 1 | # Token 2 | ### Get Blocto Token Balance 3 | ``` 4 | flow scripts execute ./scripts/token/getPredefinedLockupSchedule.cdc \ 5 | --network testnet \ 6 | --arg Int:0 7 | ``` 8 | 9 | ### Get Blocto Token Balance 10 | ``` 11 | flow scripts execute ./scripts/token/getBloctoTokenBalance.cdc \ 12 | --network testnet \ 13 | --arg Address:0x95d4f57daf2fb5ce 14 | ``` 15 | 16 | ### Get Idle Blocto Token Balance in BloctoPass 17 | ``` 18 | flow scripts execute ./scripts/token/getBloctoPassVaultBalance.cdc \ 19 | --network testnet \ 20 | --arg Address:0x95d4f57daf2fb5ce 21 | ``` 22 | 23 | ### Get Total Blocto Token Balance in BloctoPass 24 | ``` 25 | flow scripts execute ./scripts/token/getBloctoPassTotalBalance.cdc \ 26 | --network testnet \ 27 | --arg Address:0x95d4f57daf2fb5ce 28 | ``` 29 | 30 | ### Get Blocto Token Lockup Schedule in BloctoPass 31 | ``` 32 | flow scripts execute ./scripts/token/getBloctoPassLockupSchedule.cdc \ 33 | --network testnet \ 34 | --arg Address:0x67e7299327d1bf70 35 | ``` 36 | 37 | ### Get Blocto Token Lockup Amount in BloctoPass 38 | ``` 39 | flow scripts execute ./scripts/token/getBloctoPassLockupAmount.cdc \ 40 | --network testnet \ 41 | --arg Address:0x67e7299327d1bf70 42 | ``` 43 | 44 | ### Get Metadata from BloctoPass 45 | ``` 46 | flow scripts execute ./scripts/token/getBloctoPassMetadata.cdc \ 47 | --network testnet \ 48 | --arg Address:0x95d4f57daf2fb5ce 49 | ``` 50 | 51 | ### Get Original Ownder from BloctoPass 52 | ``` 53 | flow scripts execute ./scripts/token/getBloctoPassOriginalOwner.cdc \ 54 | --network testnet \ 55 | --arg Address:0x95d4f57daf2fb5ce 56 | ``` 57 | 58 | ### Get Original Ownder from BloctoPass 59 | ``` 60 | flow scripts execute ./scripts/token/getPredefinedLockupSchedule.cdc \ 61 | --network testnet \ 62 | --arg Int:0 63 | ``` 64 | -------------------------------------------------------------------------------- /scripts/token/TeleportedTetherToken/getAllowance.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportedTetherToken" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportedTetherToken.TeleportUser}>(/public/teleportedTetherTokenTeleportUser) 6 | ?? panic("Could not borrow a reference of TeleportUser") 7 | return teleportUserRef.allowedAmount 8 | } 9 | -------------------------------------------------------------------------------- /scripts/token/TeleportedTetherToken/getBalance.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | access(all) 5 | fun main(address: Address): UFix64 { 6 | let vaultRef = getAccount(address).capabilities.borrow<&{FungibleToken.Vault}>(TeleportedTetherToken.TokenPublicBalancePath) 7 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 8 | return vaultRef.balance 9 | } 10 | -------------------------------------------------------------------------------- /scripts/token/TeleportedTetherToken/getFeeAmount.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportedTetherToken" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): UFix64 { 5 | let teleportAdminRef = getAuthAccount(teleportAdmin).storage.borrow<&TeleportedTetherToken.TeleportAdmin>(from: /storage/teleportedTetherTokenTeleportAdmin) 6 | ?? panic("Could not borrow a reference of TeleportAdmin") 7 | return teleportAdminRef.getFeeAmount() 8 | } -------------------------------------------------------------------------------- /scripts/token/TeleportedTetherToken/getFees.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportedTetherToken" 2 | 3 | access(all) 4 | fun main(teleportAdmin: Address): {String: UFix64} { 5 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportedTetherToken.TeleportUser}>(/public/teleportedTetherTokenTeleportUser) 6 | ?? panic("Could not borrow a reference of TeleportUser") 7 | return { 8 | "inwardFee": teleportUserRef.inwardFee, 9 | "outwardFee": teleportUserRef.outwardFee 10 | } 11 | } -------------------------------------------------------------------------------- /scripts/token/TeleportedTetherToken/getIsFrozen.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportedTetherToken" 2 | 3 | access(all) fun main(): Bool { 4 | return TeleportedTetherToken.isFrozen 5 | } 6 | -------------------------------------------------------------------------------- /scripts/token/TeleportedTetherToken/getTotalSupply.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportedTetherToken" 2 | 3 | access(all) fun main(): UFix64 { 4 | return TeleportedTetherToken.totalSupply 5 | } 6 | -------------------------------------------------------------------------------- /scripts/token/checkFlowVault.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../contracts/flow/token/FungibleToken.cdc" 2 | import FlowToken from "../../contracts/flow/token/FlowToken.cdc" 3 | 4 | pub fun main(address: Address): Bool { 5 | return getAccount(address).getCapability<&{FungibleToken.Provider}>(/public/flowTokenReceiver).check() 6 | } 7 | -------------------------------------------------------------------------------- /scripts/token/getBloctoPassIds.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | pub fun main(address: Address): [UInt64] { 5 | let collectionRef = getAccount(address).getCapability(/public/bloctoPassCollection) 6 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 7 | ?? panic("Could not borrow collection public reference") 8 | 9 | return collectionRef.getIDs() 10 | } 11 | -------------------------------------------------------------------------------- /scripts/token/getBloctoPassLockupAmount.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | pub fun main(address: Address): UFix64 { 5 | let collectionRef = getAccount(address).getCapability(/public/bloctoPassCollection) 6 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 7 | ?? panic("Could not borrow collection public reference") 8 | 9 | let ids = collectionRef.getIDs() 10 | let bloctoPass = collectionRef.borrowBloctoPassPublic(id: ids[0]) 11 | 12 | return bloctoPass.getLockupAmount() 13 | } 14 | -------------------------------------------------------------------------------- /scripts/token/getBloctoPassLockupSchedule.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | pub fun main(address: Address): {UFix64: UFix64} { 5 | let collectionRef = getAccount(address).getCapability(/public/bloctoPassCollection) 6 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 7 | ?? panic("Could not borrow collection public reference") 8 | 9 | let ids = collectionRef.getIDs() 10 | let bloctoPass = collectionRef.borrowBloctoPassPublic(id: ids[0]) 11 | 12 | return bloctoPass.getLockupSchedule() 13 | } 14 | -------------------------------------------------------------------------------- /scripts/token/getBloctoPassMetadata.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | pub fun main(address: Address): {String: String} { 5 | let collectionRef = getAccount(address).getCapability(/public/bloctoPassCollection) 6 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 7 | ?? panic("Could not borrow collection public reference") 8 | 9 | let ids = collectionRef.getIDs() 10 | let bloctoPass = collectionRef.borrowBloctoPassPublic(id: ids[0]) 11 | 12 | return bloctoPass.getMetadata() 13 | } 14 | -------------------------------------------------------------------------------- /scripts/token/getBloctoPassOriginalOwner.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | pub fun main(address: Address): Address? { 5 | let collectionRef = getAccount(address).getCapability(/public/bloctoPassCollection) 6 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 7 | ?? panic("Could not borrow collection public reference") 8 | 9 | let ids = collectionRef.getIDs() 10 | let bloctoPass = collectionRef.borrowBloctoPassPublic(id: ids[0]) 11 | 12 | return bloctoPass.getOriginalOwner() 13 | } 14 | -------------------------------------------------------------------------------- /scripts/token/getBloctoPassTotalBalance.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | pub fun main(address: Address): UFix64 { 5 | let collectionRef = getAccount(address).getCapability(/public/bloctoPassCollection) 6 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 7 | ?? panic("Could not borrow collection public reference") 8 | 9 | let ids = collectionRef.getIDs() 10 | let bloctoPass = collectionRef.borrowBloctoPassPublic(id: ids[0]) 11 | 12 | return bloctoPass.getTotalBalance() 13 | } 14 | -------------------------------------------------------------------------------- /scripts/token/getBloctoPassVaultBalance.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | pub fun main(address: Address): UFix64 { 5 | let collectionRef = getAccount(address).getCapability(/public/bloctoPassCollection) 6 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 7 | ?? panic("Could not borrow collection public reference") 8 | 9 | let ids = collectionRef.getIDs() 10 | let bloctoPass = collectionRef.borrowBloctoPassPublic(id: ids[0]) 11 | 12 | return bloctoPass.getIdleBalance() 13 | } 14 | -------------------------------------------------------------------------------- /scripts/token/getBloctoTokenBalance.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | 4 | access(all) 5 | fun main(address: Address): UFix64 { 6 | let balanceRef = getAccount(address).capabilities.borrow<&{FungibleToken.Balance}>(BloctoToken.TokenPublicBalancePath) 7 | ?? panic("Could not borrow balance public reference") 8 | return balanceRef.balance 9 | } 10 | -------------------------------------------------------------------------------- /scripts/token/getPredefinedLockupSchedule.cdc: -------------------------------------------------------------------------------- 1 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 2 | 3 | pub fun main(id: Int): {UFix64: UFix64} { 4 | return BloctoPass.getPredefinedLockupSchedule(id: id) 5 | } 6 | -------------------------------------------------------------------------------- /scripts/token/getTotalSupply.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoToken" 2 | 3 | access(all) 4 | fun main(): UFix64 { 5 | return BloctoToken.totalSupply 6 | } 7 | -------------------------------------------------------------------------------- /transactions/dao/README.md: -------------------------------------------------------------------------------- 1 | # DAO - Examples 2 | ### Setup Proposer 3 | ``` 4 | flow transactions send ./transactions/dao/createProposer.cdc \ 5 | --signer blt-dao-admin-mainnet \ 6 | --network mainnet 7 | ``` 8 | 9 | ### Propose New Topic 10 | ``` 11 | flow transactions send ./transactions/dao/proposeNewTopic.cdc \ 12 | --signer blt-dao-admin-mainnet \ 13 | --network mainnet 14 | ``` 15 | -------------------------------------------------------------------------------- /transactions/dao/createProposer.cdc: -------------------------------------------------------------------------------- 1 | import BloctoDAO from "../../contracts/flow/dao/BloctoDAO.cdc" 2 | 3 | transaction { 4 | 5 | prepare(signer: AuthAccount) { 6 | let admin = signer 7 | .borrow<&BloctoDAO.Admin>(from: BloctoDAO.AdminStoragePath) 8 | ?? panic("Signer is not the admin") 9 | 10 | let proposer <- admin.createProposer() 11 | 12 | signer.save(<-proposer, to: /storage/bloctoDAOProposer) 13 | signer.link<&BloctoDAO.Proposer>( 14 | /private/bloctoDAOProposer, 15 | target: /storage/bloctoDAOProposer 16 | ) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/dao/proposeNewTopic.cdc: -------------------------------------------------------------------------------- 1 | import BloctoDAO from "../../contracts/flow/dao/BloctoDAO.cdc" 2 | 3 | transaction { 4 | let proposer: &BloctoDAO.Proposer 5 | 6 | prepare(signer: AuthAccount) { 7 | self.proposer = signer.getCapability(/private/bloctoDAOProposer).borrow<&BloctoDAO.Proposer>() 8 | ?? panic("Could not borrow reference") 9 | } 10 | 11 | execute { 12 | self.proposer.addTopic( 13 | title: "How much $BLT token grant should the Blocto ecosystem fund allocate for the IDO platform from portto, the infrastructure supplier?", 14 | description: "Portto is the infrastructure supplier of Blocto's upcoming IDO platform. In this poll, we wish to decide how much $BLT token should be granted to portto for developing the Blocto IDO platform via BloctoDAO. The grant will be granted from the ecosystem fund.", 15 | options: ["100K $BLT", "300K $BLT", "500K $BLT"], 16 | startAt: 1641373200.0, 17 | endAt: 1641546000.0, 18 | minVoteStakingAmount: 0.00000001 19 | ) 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /transactions/general/addKey.cdc: -------------------------------------------------------------------------------- 1 | transaction(key: String) { 2 | prepare(account: AuthAccount) { 3 | account.keys.add( 4 | publicKey: PublicKey( 5 | publicKey: key.decodeHex(), 6 | signatureAlgorithm: SignatureAlgorithm.ECDSA_secp256k1 7 | ), 8 | hashAlgorithm: HashAlgorithm.SHA2_256, 9 | weight: 1000.0 10 | ) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /transactions/general/removeKey.cdc: -------------------------------------------------------------------------------- 1 | transaction(keyIndex: Int) { 2 | prepare(signer: AuthAccount) { 3 | // revoke old recovery key 4 | signer.keys.revoke(keyIndex: keyIndex) 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /transactions/mining/README.md: -------------------------------------------------------------------------------- 1 | # Mining - Examples 2 | ### Setup Mining Reward 3 | ``` 4 | flow transactions send ./transactions/token/setupMiningReward.cdc 5 | ``` 6 | 7 | ### Get Unlock Mining Reward 8 | Return type: UFix64 9 | ``` 10 | flow scripts execute ./scripts/mining/getUnlockMiningReward.cdc \ 11 | --arg Address:0xf8d6e0586b0a20c7 12 | ``` 13 | 14 | ### Get All Mining Reward 15 | Return type: {round: UInt64: reward: UFix64} 16 | ``` 17 | flow scripts execute ./scripts/mining/getMiningReward.cdc \ 18 | --arg Address:0xf8d6e0586b0a20c7 19 | ``` 20 | 21 | ### Withdraw Mining Reward 22 | ``` 23 | flow transactions send ./transactions/mining/withdrawReward.cdc 24 | ``` -------------------------------------------------------------------------------- /transactions/mining/addDefaultCriteria.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction() { 4 | 5 | prepare(signer: AuthAccount) { 6 | let admin = signer 7 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 8 | ?? panic("Signer is not the admin") 9 | 10 | let tx = BloctoTokenMining.Criterion(reward: 1.0, divisor: 2.0, capTimes: 5) 11 | let referral = BloctoTokenMining.Criterion(reward: 5.0, divisor: 1.0, capTimes: 6) 12 | let assetInCirculation = BloctoTokenMining.Criterion(reward: 1.0, divisor: 100.0, capTimes: 10) 13 | 14 | admin.updateCriterion(name: "tx", criterion: tx) 15 | admin.updateCriterion(name: "referral", criterion: referral) 16 | admin.updateCriterion(name: "assetInCirculation", criterion: assetInCirculation) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/mining/collectData.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction(address: Address, tx: UFix64, referral: UFix64, assetInCirculation: UFix64) { 4 | 5 | prepare(signer: AuthAccount) { 6 | let admin = signer 7 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 8 | ?? panic("Signer is not the admin") 9 | 10 | let data = { 11 | "tx": tx, 12 | "referral": referral, 13 | "assetInCirculation": assetInCirculation 14 | } 15 | 16 | admin.collectData(data, address: address) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/mining/distributeReward.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction(address: Address) { 4 | 5 | prepare(signer: AuthAccount) { 6 | let admin = signer 7 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 8 | ?? panic("Signer is not the admin") 9 | 10 | admin.distributeReward(address: address) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /transactions/mining/finishDistributing.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction() { 4 | prepare(signer: AuthAccount) { 5 | let admin = signer 6 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 7 | ?? panic("Signer is not the admin") 8 | 9 | admin.finishDistributing() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/mining/goNextRound.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction() { 4 | prepare(signer: AuthAccount) { 5 | let admin = signer 6 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 7 | ?? panic("Signer is not the admin") 8 | 9 | admin.goNextRound() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/mining/removeCriteria.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction(name: String) { 4 | 5 | prepare(signer: AuthAccount) { 6 | let admin = signer 7 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 8 | ?? panic("Signer is not the admin") 9 | 10 | admin.updateCriterion(name: name, criterion: nil) 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /transactions/mining/setupMiningReward.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction { 4 | 5 | prepare(signer: AuthAccount) { 6 | if signer.borrow<&BloctoTokenMining.MiningReward>(from: BloctoTokenMining.MiningRewardStoragePath) == nil { 7 | 8 | let miningReward <- BloctoTokenMining.createEmptyMiningReward() 9 | 10 | signer.save(<-miningReward, to: BloctoTokenMining.MiningRewardStoragePath) 11 | 12 | signer.link<&{BloctoTokenMining.MiningRewardPublic}>( 13 | BloctoTokenMining.MiningRewardPublicPath, 14 | target: BloctoTokenMining.MiningRewardStoragePath) 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /transactions/mining/startCollecting.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction() { 4 | prepare(signer: AuthAccount) { 5 | let admin = signer 6 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 7 | ?? panic("Signer is not the admin") 8 | 9 | admin.startCollecting() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/mining/stopCollecting.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction() { 4 | prepare(signer: AuthAccount) { 5 | let admin = signer 6 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 7 | ?? panic("Signer is not the admin") 8 | 9 | admin.stopCollecting() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/mining/updateCriteria.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction(name: String, reward: UFix64, divisor: UFix64, capTimes: UInt64) { 4 | 5 | prepare(signer: AuthAccount) { 6 | let admin = signer 7 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 8 | ?? panic("Signer is not the admin") 9 | 10 | let criteria = BloctoTokenMining.Criterion(reward: reward, divisor: divisor, capTimes: capTimes) 11 | 12 | admin.updateCriterion(name: name, criterion: criteria) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /transactions/mining/updateRewardCap.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction(rewardCap: UFix64) { 4 | prepare(signer: AuthAccount) { 5 | let admin = signer 6 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 7 | ?? panic("Signer is not the admin") 8 | 9 | admin.updateRewardCap(rewardCap) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/mining/updateRewardLockPeriod.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction(rewardLockPeriod: UInt64) { 4 | prepare(signer: AuthAccount) { 5 | let admin = signer 6 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 7 | ?? panic("Signer is not the admin") 8 | 9 | admin.updateRewardLockPeriod(rewardLockPeriod) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/mining/updateRewardLockRatio.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | 3 | transaction(rewardLockRatio: UFix64) { 4 | prepare(signer: AuthAccount) { 5 | let admin = signer 6 | .borrow<&BloctoTokenMining.Administrator>(from: /storage/bloctoTokenMiningAdmin) 7 | ?? panic("Signer is not the admin") 8 | 9 | admin.updateRewardLockRatio(rewardLockRatio) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/mining/withdrawReward.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenMining from "../../contracts/flow/mining/BloctoTokenMining.cdc" 2 | import BloctoToken from "../../contracts/flow/token/BloctoToken.cdc" 3 | 4 | transaction { 5 | 6 | prepare(signer: AuthAccount) { 7 | let vaultRef = signer.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 8 | ?? panic("Could not borrow reference to the owner's Vault!") 9 | 10 | let miningRewardRef = signer.borrow<&BloctoTokenMining.MiningReward>(from: BloctoTokenMining.MiningRewardStoragePath) 11 | ?? panic("Could not borrow reference to the owner's mining reward!") 12 | 13 | let rewardVault <- miningRewardRef.withdraw() 14 | vaultRef.deposit(from: <- rewardVault) 15 | } 16 | } -------------------------------------------------------------------------------- /transactions/sale/community/README.md: -------------------------------------------------------------------------------- 1 | # Swap 2 | ### Freeze Sale 3 | ``` 4 | flow transactions send ./transactions/sale/community/freeze.cdc \ 5 | --network testnet \ 6 | --signer blt-admin-testnet \ 7 | --gas-limit 1000 8 | ``` 9 | 10 | ### Unfreeze Sale 11 | ``` 12 | flow transactions send ./transactions/sale/community/unfreeze.cdc \ 13 | --network testnet \ 14 | --signer blt-admin-testnet \ 15 | --gas-limit 1000 16 | ``` 17 | 18 | ### Deposit BLT by Admin 19 | ``` 20 | flow transactions send ./transactions/sale/community/depositBLT.cdc \ 21 | --network testnet \ 22 | --arg UFix64:50000.0 \ 23 | --signer blt-admin-testnet \ 24 | --gas-limit 1000 25 | ``` 26 | 27 | ### Withdraw tUSDT by Admin 28 | ``` 29 | flow transactions send ./transactions/sale/community/withdrawTusdt.cdc \ 30 | --network testnet \ 31 | --arg UFix64:50000.0 \ 32 | --arg Address:0x03d1e02a48354e2b \ 33 | --signer blt-admin-testnet \ 34 | --gas-limit 1000 35 | ``` 36 | 37 | ### Update Lockup Schedule ID 38 | ``` 39 | flow transactions send ./transactions/sale/community/updateLockupScheduleId.cdc \ 40 | --network testnet \ 41 | --arg Int:1 \ 42 | --signer blt-admin-testnet \ 43 | --gas-limit 1000 44 | ``` 45 | 46 | ### Purchase BLT 47 | ``` 48 | flow transactions send ./transactions/sale/community/purchaseBLT.cdc \ 49 | --network testnet \ 50 | --arg UFix64:500.0 \ 51 | --signer blt-user-testnet \ 52 | --gas-limit 1000 53 | ``` 54 | 55 | ### Distribute BLT to Purchaser 56 | ``` 57 | flow transactions send ./transactions/sale/community/distribute.cdc \ 58 | --network testnet \ 59 | --arg Address:0x67e7299327d1bf70 \ 60 | --signer blt-admin-testnet \ 61 | --gas-limit 1000 62 | ``` 63 | 64 | ### Distribute Locked BLT to Purchaser in a Batch 65 | ``` 66 | flow transactions send ./transactions/sale/community/distributeBatch.cdc \ 67 | --network testnet \ 68 | --args-json "$(cat "./arguments/distribute.json")" \ 69 | --signer blt-admin-new-testnet \ 70 | --gas-limit 9999 71 | ``` 72 | 73 | ### Refund tUSDT to Purchaser 74 | ``` 75 | flow transactions send ./transactions/sale/community/refund.cdc \ 76 | --network testnet \ 77 | --arg Address:0x95d4f57daf2fb5ce \ 78 | --signer blt-admin-testnet \ 79 | --gas-limit 1000 80 | ``` 81 | 82 | ### Refund tUSDT to Purchaser in a Batch 83 | ``` 84 | flow transactions send ./transactions/sale/community/refundBatch.cdc \ 85 | --network testnet \ 86 | --args-json "$(cat "./arguments/refund.json")" \ 87 | --signer blt-admin-new-testnet \ 88 | --gas-limit 9999 89 | ``` 90 | -------------------------------------------------------------------------------- /transactions/sale/community/depositBLT.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 3 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 4 | 5 | transaction(amount: UFix64) { 6 | 7 | // The reference to the Admin Resource 8 | let adminRef: &BloctoTokenSale.Admin 9 | 10 | // The tUSDT Vault resource that holds the tokens that are being transferred 11 | let sentVault: @FungibleToken.Vault 12 | 13 | prepare(account: AuthAccount) { 14 | 15 | // Get admin reference 16 | self.adminRef = account.borrow<&BloctoTokenSale.Admin>(from: BloctoTokenSale.SaleAdminStoragePath) 17 | ?? panic("Could not borrow reference to the admin!") 18 | 19 | // Get a reference to the signer's stored vault 20 | let vaultRef = account.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 21 | ?? panic("Could not borrow reference to the owner's Vault!") 22 | 23 | // Withdraw tokens from the signer's stored vault 24 | self.sentVault <- vaultRef.withdraw(amount: amount) 25 | } 26 | 27 | execute { 28 | 29 | // Deposit BLT 30 | self.adminRef.depositBlt(from: <-self.sentVault) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /transactions/sale/community/distribute.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | transaction(address: Address) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenSale.Admin>(from: BloctoTokenSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Distribute BLT purchase 18 | self.adminRef.distribute(address: address) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/sale/community/distributeBatch.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | transaction(addresses: [Address]) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenSale.Admin>(from: BloctoTokenSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Distribute BLT purchase to all addresses in the list 18 | for address in addresses { 19 | self.adminRef.distribute(address: address) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /transactions/sale/community/freeze.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | transaction() { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenSale.Admin>(from: BloctoTokenSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Freeze sale 18 | self.adminRef.freeze() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/sale/community/purchaseBLT.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 2 | import TeleportedTetherToken from "../../../contracts/flow/token/TeleportedTetherToken.cdc" 3 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 4 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 5 | 6 | transaction(amount: UFix64) { 7 | 8 | // The tUSDT Vault resource that holds the tokens that are being transferred 9 | let sentVault: @TeleportedTetherToken.Vault 10 | 11 | // The address of the BLT buyer 12 | let buyerAddress: Address 13 | 14 | prepare(account: AuthAccount) { 15 | 16 | // Get a reference to the signer's stored vault 17 | let vaultRef = account.borrow<&TeleportedTetherToken.Vault>(from: TeleportedTetherToken.TokenStoragePath) 18 | ?? panic("Could not borrow reference to the owner's Vault!") 19 | 20 | // Withdraw tokens from the signer's stored vault 21 | self.sentVault <- vaultRef.withdraw(amount: amount) as! @TeleportedTetherToken.Vault 22 | 23 | // Record the buyer address 24 | self.buyerAddress = account.address 25 | 26 | // If user does not have BloctoPass collection yet, create one to receive 27 | if account.borrow<&BloctoPass.Collection>(from: BloctoPass.CollectionStoragePath) == nil { 28 | 29 | let collection <- BloctoPass.createEmptyCollection() as! @BloctoPass.Collection 30 | 31 | account.save(<-collection, to: BloctoPass.CollectionStoragePath) 32 | 33 | account.link<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>( 34 | BloctoPass.CollectionPublicPath, 35 | target: BloctoPass.CollectionStoragePath) 36 | } 37 | } 38 | 39 | execute { 40 | 41 | // Enroll in BLT community sale 42 | BloctoTokenSale.purchase(from: <-self.sentVault, address: self.buyerAddress) 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /transactions/sale/community/refund.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | transaction(address: Address) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenSale.Admin>(from: BloctoTokenSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Refun BLT purchase 18 | self.adminRef.refund(address: address) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/sale/community/refundBatch.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | transaction(addresses: [Address]) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenSale.Admin>(from: BloctoTokenSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Refun BLT purchase to all addresses in the list 18 | for address in addresses { 19 | self.adminRef.refund(address: address) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /transactions/sale/community/unfreeze.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | transaction() { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenSale.Admin>(from: BloctoTokenSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Unfreeze sale 18 | self.adminRef.unfreeze() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/sale/community/updateLockupScheduleId.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 2 | 3 | transaction(lockupScheduleId: Int) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenSale.Admin>(from: BloctoTokenSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Refun BLT purchase 18 | self.adminRef.updateLockupScheduleId(lockupScheduleId: lockupScheduleId) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/sale/community/withdrawTusdt.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import TeleportedTetherToken from "../../../contracts/flow/token/TeleportedTetherToken.cdc" 3 | import BloctoTokenSale from "../../../contracts/flow/sale/BloctoTokenSale.cdc" 4 | 5 | transaction(amount: UFix64, to: Address) { 6 | 7 | // The reference to the Admin Resource 8 | let adminRef: &BloctoTokenSale.Admin 9 | 10 | prepare(signer: AuthAccount) { 11 | 12 | // Get admin reference 13 | self.adminRef = signer.borrow<&BloctoTokenSale.Admin>(from: BloctoTokenSale.SaleAdminStoragePath) 14 | ?? panic("Could not borrow reference to the admin!") 15 | } 16 | 17 | execute { 18 | 19 | // Withdraw tUSDT from sale contract 20 | let vault <- self.adminRef.withdrawTusdt(amount: amount) 21 | 22 | // Get the recipient's public account object 23 | let recipient = getAccount(to) 24 | 25 | // Get a reference to the recipient's Receiver 26 | let receiverRef = recipient.getCapability(TeleportedTetherToken.TokenPublicReceiverPath) 27 | .borrow<&{FungibleToken.Receiver}>() 28 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 29 | 30 | // Deposit the withdrawn tokens in the recipient's receiver 31 | receiverRef.deposit(from: <- vault) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /transactions/sale/public/README.md: -------------------------------------------------------------------------------- 1 | # Swap 2 | ### Freeze Sale 3 | ``` 4 | flow transactions send ./transactions/sale/public/freeze.cdc \ 5 | --network testnet \ 6 | --signer blt-admin-new-testnet \ 7 | --gas-limit 1000 8 | ``` 9 | 10 | ### Unfreeze Sale 11 | ``` 12 | flow transactions send ./transactions/sale/public/unfreeze.cdc \ 13 | --network testnet \ 14 | --signer blt-admin-new-testnet \ 15 | --gas-limit 1000 16 | ``` 17 | 18 | ### Deposit BLT by Admin 19 | ``` 20 | flow transactions send ./transactions/sale/public/depositBLT.cdc \ 21 | --network testnet \ 22 | --arg UFix64:50000.0 \ 23 | --signer blt-admin-testnet \ 24 | --gas-limit 1000 25 | ``` 26 | 27 | ### Withdraw tUSDT by Admin 28 | ``` 29 | flow transactions send ./transactions/sale/public/withdrawTusdt.cdc \ 30 | --network mainnet \ 31 | --arg UFix64:600000.00000203 \ 32 | --arg Address:0xf27a6d7cf6eee316 \ 33 | --signer blt-sale-admin-mainnet \ 34 | --gas-limit 1000 35 | ``` 36 | 37 | ### Withdraw BLT by Admin 38 | ``` 39 | flow transactions send ./transactions/sale/public/withdrawBLT.cdc \ 40 | --network mainnet \ 41 | --arg UFix64:0.00000249 \ 42 | --arg Address:0x0f9df91c9121c460 \ 43 | --signer blt-sale-admin-mainnet \ 44 | --gas-limit 1000 45 | ``` 46 | 47 | ### Purchase BLT 48 | ``` 49 | flow transactions send ./transactions/sale/public/purchaseBLT.cdc \ 50 | --network testnet \ 51 | --arg UFix64:500.0 \ 52 | --signer blt-user-testnet \ 53 | --gas-limit 1000 54 | ``` 55 | 56 | ### Distribute BLT to Purchaser 57 | ``` 58 | flow transactions send ./transactions/sale/public/distribute.cdc \ 59 | --network testnet \ 60 | --arg Address:0x67e7299327d1bf70 \ 61 | --arg UFix64:500.0 \ 62 | --signer blt-admin-testnet \ 63 | --gas-limit 1000 64 | ``` 65 | 66 | ### Distribute Locked BLT to Purchaser in a Batch 67 | ``` 68 | flow transactions send ./transactions/sale/public/distributeBatch.cdc \ 69 | --network mainnet \ 70 | --args-json "$(cat "./arguments/batch/distributeWithAmount.json")" \ 71 | --signer blt-sale-admin-mainnet \ 72 | --gas-limit 9999 73 | ``` 74 | 75 | ### Refund tUSDT to Purchaser 76 | ``` 77 | flow transactions send ./transactions/sale/public/refund.cdc \ 78 | --network testnet \ 79 | --arg Address:0x95d4f57daf2fb5ce \ 80 | --signer blt-admin-new-testnet \ 81 | --gas-limit 1000 82 | ``` 83 | 84 | ### Refund tUSDT to Purchaser in a Batch 85 | ``` 86 | flow transactions send ./transactions/sale/public/refundBatch.cdc \ 87 | --network testnet \ 88 | --args-json "$(cat "./arguments/refund.json")" \ 89 | --signer blt-admin-new-testnet \ 90 | --gas-limit 9999 91 | ``` 92 | 93 | ### Add New Keys 94 | ``` 95 | flow transactions send ./transactions/sale/public/addPublicKey.cdc \ 96 | --network mainnet \ 97 | --arg String:75861f4a7b81746df8f0199d0f95d1261085b3ba3d4b1f0221fbf18284d4b759aed989a193b9e89f84932473ac5195475bd3d3081ad0180c20d5811b49e6d9c1 \ 98 | --signer blt-sale-admin-mainnet \ 99 | --gas-limit 9999 100 | ``` 101 | -------------------------------------------------------------------------------- /transactions/sale/public/addPublicKey.cdc: -------------------------------------------------------------------------------- 1 | transaction(publicKey: String) { 2 | prepare(account: AuthAccount) { 3 | let key = PublicKey( 4 | publicKey: publicKey.decodeHex(), 5 | signatureAlgorithm: SignatureAlgorithm.ECDSA_secp256k1 6 | ) 7 | 8 | account.keys.add( 9 | publicKey: key, 10 | hashAlgorithm: HashAlgorithm.SHA3_256, 11 | weight: 1000.0 12 | ) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /transactions/sale/public/depositBLT.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 3 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 4 | 5 | transaction(amount: UFix64) { 6 | 7 | // The reference to the Admin Resource 8 | let adminRef: &BloctoTokenPublicSale.Admin 9 | 10 | // The tUSDT Vault resource that holds the tokens that are being transferred 11 | let sentVault: @FungibleToken.Vault 12 | 13 | prepare(account: AuthAccount) { 14 | 15 | // Get admin reference 16 | self.adminRef = account.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 17 | ?? panic("Could not borrow reference to the admin!") 18 | 19 | // Get a reference to the signer's stored vault 20 | let vaultRef = account.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 21 | ?? panic("Could not borrow reference to the owner's Vault!") 22 | 23 | // Withdraw tokens from the signer's stored vault 24 | self.sentVault <- vaultRef.withdraw(amount: amount) 25 | } 26 | 27 | execute { 28 | 29 | // Deposit BLT 30 | self.adminRef.depositBlt(from: <-self.sentVault) 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /transactions/sale/public/distribute.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | transaction(address: Address, allocationAmount: UFix64) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenPublicSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Distribute BLT purchase 18 | self.adminRef.distribute(address: address, allocationAmount: allocationAmount) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/sale/public/distributeBatch.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | transaction(addresses: [Address], allocationAmounts: [UFix64]) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenPublicSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | assert( 10 | addresses.length == allocationAmounts.length, 11 | message: "Input length mismatch" 12 | ) 13 | 14 | // Get admin reference 15 | self.adminRef = account.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 16 | ?? panic("Could not borrow reference to the admin!") 17 | } 18 | 19 | execute { 20 | 21 | // Distribute BLT purchase to all addresses in the list 22 | var index = 0 23 | while index < addresses.length { 24 | self.adminRef.distribute(address: addresses[index], allocationAmount: allocationAmounts[index]) 25 | index = index + 1 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /transactions/sale/public/distributeBatchFull.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | transaction(addresses: [Address]) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenPublicSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Distribute BLT purchase to all addresses in the list 18 | for address in addresses { 19 | let purchaseInfo = BloctoTokenPublicSale.getPurchase(address: address)! 20 | self.adminRef.distribute(address: address, allocationAmount: purchaseInfo.amount) 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /transactions/sale/public/freeze.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | transaction() { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenPublicSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Freeze sale 18 | self.adminRef.freeze() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/sale/public/purchaseBLT.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 2 | import TeleportedTetherToken from "../../../contracts/flow/token/TeleportedTetherToken.cdc" 3 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 4 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 5 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 6 | 7 | transaction(amount: UFix64) { 8 | 9 | // The tUSDT Vault resource that holds the tokens that are being transferred 10 | let sentVault: @TeleportedTetherToken.Vault 11 | 12 | // The address of the BLT buyer 13 | let buyerAddress: Address 14 | 15 | prepare(account: AuthAccount) { 16 | 17 | // Get a reference to the signer's stored vault 18 | let vaultRef = account.borrow<&TeleportedTetherToken.Vault>(from: TeleportedTetherToken.TokenStoragePath) 19 | ?? panic("Could not borrow reference to the owner's Vault!") 20 | 21 | // Withdraw tokens from the signer's stored vault 22 | self.sentVault <- vaultRef.withdraw(amount: amount) as! @TeleportedTetherToken.Vault 23 | 24 | // Record the buyer address 25 | self.buyerAddress = account.address 26 | 27 | // Create BloctoToken vault if not currently available 28 | if(account.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) == nil) { 29 | 30 | // Create a new Blocto Token Vault and put it in storage 31 | account.save(<-BloctoToken.createEmptyVault(), to: BloctoToken.TokenStoragePath) 32 | 33 | // Create a public capability to the Vault that only exposes 34 | // the deposit function through the Receiver interface 35 | account.link<&BloctoToken.Vault{FungibleToken.Receiver}>( 36 | BloctoToken.TokenPublicReceiverPath, 37 | target: BloctoToken.TokenStoragePath 38 | ) 39 | 40 | // Create a public capability to the Vault that only exposes 41 | // the balance field through the Balance interface 42 | account.link<&BloctoToken.Vault{FungibleToken.Balance}>( 43 | BloctoToken.TokenPublicBalancePath, 44 | target: BloctoToken.TokenStoragePath 45 | ) 46 | } 47 | } 48 | 49 | execute { 50 | 51 | // Enroll in BLT community sale 52 | BloctoTokenPublicSale.purchase(from: <-self.sentVault, address: self.buyerAddress) 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /transactions/sale/public/refund.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | transaction(address: Address) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenPublicSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Refun BLT purchase 18 | self.adminRef.refund(address: address) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/sale/public/refundBatch.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | transaction(addresses: [Address]) { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenPublicSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Refun BLT purchase to all addresses in the list 18 | for address in addresses { 19 | self.adminRef.refund(address: address) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /transactions/sale/public/unfreeze.cdc: -------------------------------------------------------------------------------- 1 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 2 | 3 | transaction() { 4 | 5 | // The reference to the Admin Resource 6 | let adminRef: &BloctoTokenPublicSale.Admin 7 | 8 | prepare(account: AuthAccount) { 9 | 10 | // Get admin reference 11 | self.adminRef = account.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 12 | ?? panic("Could not borrow reference to the admin!") 13 | } 14 | 15 | execute { 16 | 17 | // Unfreeze sale 18 | self.adminRef.unfreeze() 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/sale/public/withdrawBLT.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 3 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 4 | 5 | transaction(amount: UFix64, to: Address) { 6 | 7 | // The reference to the Admin Resource 8 | let adminRef: &BloctoTokenPublicSale.Admin 9 | 10 | prepare(signer: AuthAccount) { 11 | 12 | // Get admin reference 13 | self.adminRef = signer.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 14 | ?? panic("Could not borrow reference to the admin!") 15 | } 16 | 17 | execute { 18 | 19 | // Withdraw BLT from sale contract 20 | let vault <- self.adminRef.withdrawBlt(amount: amount) 21 | 22 | // Get the recipient's public account object 23 | let recipient = getAccount(to) 24 | 25 | // Get a reference to the recipient's Receiver 26 | let receiverRef = recipient.getCapability(BloctoToken.TokenPublicReceiverPath) 27 | .borrow<&{FungibleToken.Receiver}>() 28 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 29 | 30 | // Deposit the withdrawn tokens in the recipient's receiver 31 | receiverRef.deposit(from: <- vault) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /transactions/sale/public/withdrawTusdt.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import TeleportedTetherToken from "../../../contracts/flow/token/TeleportedTetherToken.cdc" 3 | import BloctoTokenPublicSale from "../../../contracts/flow/sale/BloctoTokenPublicSale.cdc" 4 | 5 | transaction(amount: UFix64, to: Address) { 6 | 7 | // The reference to the Admin Resource 8 | let adminRef: &BloctoTokenPublicSale.Admin 9 | 10 | prepare(signer: AuthAccount) { 11 | 12 | // Get admin reference 13 | self.adminRef = signer.borrow<&BloctoTokenPublicSale.Admin>(from: BloctoTokenPublicSale.SaleAdminStoragePath) 14 | ?? panic("Could not borrow reference to the admin!") 15 | } 16 | 17 | execute { 18 | 19 | // Withdraw tUSDT from sale contract 20 | let vault <- self.adminRef.withdrawTusdt(amount: amount) 21 | 22 | // Get the recipient's public account object 23 | let recipient = getAccount(to) 24 | 25 | // Get a reference to the recipient's Receiver 26 | let receiverRef = recipient.getCapability(TeleportedTetherToken.TokenPublicReceiverPath) 27 | .borrow<&{FungibleToken.Receiver}>() 28 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 29 | 30 | // Deposit the withdrawn tokens in the recipient's receiver 31 | receiverRef.deposit(from: <- vault) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /transactions/staking/README copy.md: -------------------------------------------------------------------------------- 1 | # Staking 2 | ### Stake BLT into BloctoPass 3 | ``` 4 | flow transactions send ./transactions/staking/stakeNewTokens.cdc \ 5 | --network testnet \ 6 | --arg UFix64:1000.0 \ 7 | --signer blt-user-testnet \ 8 | --gas-limit 1000 9 | ``` 10 | 11 | ### Stake BLT that is Already in BloctoPass 12 | ``` 13 | flow transactions send ./transactions/staking/stakeNewTokensFromBloctoPass.cdc \ 14 | --network testnet \ 15 | --arg UFix64:1000.0 \ 16 | --signer blt-user-testnet \ 17 | --gas-limit 1000 18 | ``` 19 | 20 | ### Set Epoch Token Payout 21 | ``` 22 | flow transactions send ./transactions/staking/setEpochTokenPayout.cdc \ 23 | --network testnet \ 24 | --arg UFix64:1000.0 \ 25 | --signer blt-mining-testnet \ 26 | --gas-limit 1000 27 | ``` 28 | 29 | ### Switch Epoch 30 | ``` 31 | flow transactions send ./transactions/staking/switchEpoch.cdc \ 32 | --network testnet \ 33 | --signer blt-mining-testnet \ 34 | --gas-limit 1000 35 | ``` 36 | 37 | ### Setup Staking Admin 38 | ``` 39 | flow transactions build ./transactions/staking/setupStakingAdmin.cdc \ 40 | --network mainnet \ 41 | --proposer 0x0f9df91c9121c460 \ 42 | --proposer-key-index 0 \ 43 | --authorizer 0x0f9df91c9121c460 \ 44 | --authorizer 0x6a5a9c49e5b2ad53 \ 45 | --payer 0x6a5a9c49e5b2ad53 \ 46 | --gas-limit 1000 \ 47 | -x payload \ 48 | --save ./build/unsigned.rlp 49 | 50 | flow transactions sign ./build/unsigned.rlp \ 51 | --signer blt-admin-mainnet \ 52 | --filter payload \ 53 | --save ./build/signed-1.rlp 54 | 55 | flow transactions sign ./build/signed-1.rlp \ 56 | --signer blt-staking-admin-mainnet \ 57 | --filter payload \ 58 | --save ./build/signed-2.rlp 59 | 60 | flow transactions send-signed --network mainnet ./build/signed-2.rlp 61 | ``` -------------------------------------------------------------------------------- /transactions/staking/app/ClaimRewardBlt.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "NonFungibleToken" 3 | import "BloctoToken" 4 | import "BloctoPass" 5 | 6 | transaction(amount: UFix64, index: Int) { 7 | 8 | // The Vault resource that holds the tokens that are being transferred 9 | let vaultRef: &BloctoToken.Vault 10 | 11 | // The private reference to user's BloctoPass 12 | let bloctoPassRef: auth(BloctoPass.BloctoPassPrivateEntitlement) &BloctoPass.NFT 13 | 14 | // The withdraw auth reference to user's BloctoPass 15 | let bloctoPassWithdrawAuth: auth(FungibleToken.Withdraw) &BloctoPass.NFT 16 | 17 | prepare(account: auth(BorrowValue) &Account) { 18 | // Get a reference to the account's stored vault 19 | self.vaultRef = account.storage.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 20 | ?? panic("Could not borrow reference to the owner's Vault!") 21 | 22 | // Get a reference to the account's BloctoPass 23 | let bloctoPassCollectionRef = account.storage.borrow 24 | 25 | (from: /storage/bloctoPassCollection) 26 | ?? panic("Could not borrow reference to the owner's BloctoPass collection!") 27 | 28 | let ids = bloctoPassCollectionRef.getIDs() 29 | 30 | // Get a reference to the BloctoPass 31 | self.bloctoPassRef = bloctoPassCollectionRef.borrowBloctoPassPrivate(id: ids[index]) 32 | 33 | // Get a reference to the BloctoPass withdraw 34 | self.bloctoPassWithdrawAuth = bloctoPassCollectionRef.borrowWithdraw(id: ids[index]) 35 | } 36 | 37 | execute { 38 | self.bloctoPassRef.withdrawRewardedTokens(amount: amount) 39 | 40 | // Unlock as much as possible 41 | let limit = self.bloctoPassRef.getTotalBalance() - self.bloctoPassRef.getLockupAmount() 42 | let max = limit > amount ? amount : limit 43 | 44 | self.vaultRef.deposit(from: <-self.bloctoPassWithdrawAuth.withdraw(amount: max)) 45 | } 46 | } -------------------------------------------------------------------------------- /transactions/staking/app/ClaimUnstakedBlt.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "BloctoPass" 4 | 5 | transaction(amount: UFix64, index: Int) { 6 | 7 | // The Vault resource that holds the tokens that are being transferred 8 | let vaultRef: &BloctoToken.Vault 9 | 10 | // The private reference to user's BloctoPass 11 | let bloctoPassRef: auth(BloctoPass.BloctoPassPrivateEntitlement) &BloctoPass.NFT 12 | 13 | // The withdraw auth reference to user's BloctoPass 14 | let bloctoPassWithdrawAuth: auth(FungibleToken.Withdraw) &BloctoPass.NFT 15 | 16 | prepare(account: auth(BorrowValue, Capabilities) &Account) { 17 | // Get a reference to the account's stored vault 18 | self.vaultRef = account.storage.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 19 | ?? panic("Could not borrow reference to the owner's Vault!") 20 | 21 | // Get a reference to the account's BloctoPass 22 | let bloctoPassCollectionRef = account.storage.borrow 23 | 24 | (from: /storage/bloctoPassCollection) 25 | ?? panic("Could not borrow reference to the owner's BloctoPass collection!") 26 | 27 | let ids = bloctoPassCollectionRef.getIDs() 28 | 29 | // Get a reference to the BloctoPass 30 | self.bloctoPassRef = bloctoPassCollectionRef.borrowBloctoPassPrivate(id: ids[index]) 31 | 32 | // Get a reference to the BloctoPass withdraw 33 | self.bloctoPassWithdrawAuth = bloctoPassCollectionRef.borrowWithdraw(id: ids[index]) 34 | 35 | } 36 | 37 | execute { 38 | self.bloctoPassRef.withdrawUnstakedTokens(amount: amount) 39 | 40 | // Unlock as much as possible 41 | let limit = self.bloctoPassRef.getTotalBalance() - self.bloctoPassRef.getLockupAmount() 42 | let max = limit > amount ? amount : limit 43 | 44 | if (max > 0.0) { 45 | self.vaultRef.deposit(from: <-self.bloctoPassWithdrawAuth.withdraw(amount: max)) 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /transactions/staking/app/RequestToUnstakeBlt.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoPass" 2 | 3 | transaction(amount: UFix64, index: Int) { 4 | // The private reference to user's BloctoPass 5 | let bloctoPassRef: auth(BloctoPass.BloctoPassPrivateEntitlement) &BloctoPass.NFT 6 | 7 | prepare(account: auth(BorrowValue, SaveValue, Capabilities) &Account) { 8 | // Get a reference to the account's BloctoPass 9 | let bloctoPassCollectionRef = account.storage.borrow(from: /storage/bloctoPassCollection) 10 | ?? panic("Could not borrow reference to the owner's BloctoPass collection!") 11 | 12 | let ids = bloctoPassCollectionRef.getIDs() 13 | 14 | // Get a reference to the BloctoPass 15 | self.bloctoPassRef = bloctoPassCollectionRef.borrowBloctoPassPrivate(id: ids[index]) 16 | } 17 | 18 | execute { 19 | self.bloctoPassRef.requestUnstaking(amount: amount) 20 | } 21 | } -------------------------------------------------------------------------------- /transactions/staking/app/StakeNewBlt.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "BloctoPass" 4 | 5 | transaction(amount: UFix64, index: Int) { 6 | 7 | // The Vault resource that holds the tokens that are being transferred 8 | let vaultRef: auth(FungibleToken.Withdraw) &BloctoToken.Vault 9 | 10 | // The private reference to user's BloctoPass 11 | let bloctoPassRef: auth(BloctoPass.BloctoPassPrivateEntitlement) &BloctoPass.NFT 12 | 13 | prepare(account: auth(BorrowValue) &Account) { 14 | // Get a reference to the account's stored vault 15 | self.vaultRef = account.storage.borrow(from: BloctoToken.TokenStoragePath) 16 | ?? panic("Could not borrow reference to the owner's Vault!") 17 | 18 | // Get a reference to the account's BloctoPass 19 | let bloctoPassCollectionRef = account.storage.borrow(from: /storage/bloctoPassCollection) 20 | ?? panic("Could not borrow reference to the owner's BloctoPass collection!") 21 | 22 | let ids = bloctoPassCollectionRef.getIDs() 23 | 24 | // Get a reference to the BloctoPass 25 | self.bloctoPassRef = bloctoPassCollectionRef.borrowBloctoPassPrivate(id: ids[index]) 26 | } 27 | 28 | execute { 29 | let lockedBalance = self.bloctoPassRef.getIdleBalance() 30 | 31 | if amount <= lockedBalance { 32 | self.bloctoPassRef.stakeNewTokens(amount: amount) 33 | } else if ((amount - lockedBalance) <= self.vaultRef.balance) { 34 | self.bloctoPassRef.deposit(from: <-self.vaultRef.withdraw(amount: amount - lockedBalance)) 35 | self.bloctoPassRef.stakeNewTokens(amount: amount) 36 | } else { 37 | panic("Not enough tokens to stake!") 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /transactions/staking/app/StakeUnstakedBlt.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoPass" 2 | 3 | transaction(amount: UFix64, index: Int) { 4 | // The private reference to user's BloctoPass 5 | let bloctoPassRef: auth(BloctoPass.BloctoPassPrivateEntitlement) &BloctoPass.NFT 6 | 7 | prepare(account: auth(BorrowValue) &Account) { 8 | // Get a reference to the account's BloctoPass 9 | let bloctoPassCollectionRef = account.storage.borrow(from: /storage/bloctoPassCollection) 10 | ?? panic("Could not borrow reference to the owner's BloctoPass collection!") 11 | 12 | let ids = bloctoPassCollectionRef.getIDs() 13 | 14 | // Get a reference to the BloctoPass 15 | self.bloctoPassRef = bloctoPassCollectionRef.borrowBloctoPassPrivate(id: ids[index]) 16 | } 17 | 18 | execute { 19 | self.bloctoPassRef.stakeUnstakedTokens(amount: amount) 20 | } 21 | } -------------------------------------------------------------------------------- /transactions/staking/setEpoch.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoTokenStaking" 2 | transaction(epoch: UInt64) { 3 | prepare(acct: auth(Storage, SaveValue) &Account) { 4 | acct.storage.load(from: /storage/bloctoTokenStakingEpoch) 5 | acct.storage.save(epoch, to: /storage/bloctoTokenStakingEpoch) 6 | } 7 | } 8 | 9 | -------------------------------------------------------------------------------- /transactions/staking/setEpochTokenPayout.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoTokenStaking" 2 | 3 | transaction(amount: UFix64) { 4 | 5 | // Local variable for a reference to the ID Table Admin object 6 | let adminRef: auth(BloctoTokenStaking.AdminEntitlement) &BloctoTokenStaking.Admin 7 | 8 | prepare(acct: auth(BorrowValue) &Account) { 9 | // borrow a reference to the admin object 10 | self.adminRef = acct.storage.borrow(from: BloctoTokenStaking.StakingAdminStoragePath) 11 | ?? panic("Could not borrow reference to staking admin") 12 | } 13 | 14 | execute { 15 | self.adminRef.setEpochTokenPayout(amount) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /transactions/staking/setupStakingAdmin.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoTokenStaking" 2 | 3 | transaction() { 4 | prepare(admin: auth(BorrowValue) &Account, newAdmin: auth(Storage) &Account) { 5 | let adminRef = 6 | admin.storage.borrow 7 | (from: BloctoTokenStaking.StakingAdminStoragePath) 8 | ?? panic("Signer is not the admin") 9 | 10 | destroy newAdmin.storage.load<@BloctoTokenStaking.Admin>(from: BloctoTokenStaking.StakingAdminStoragePath) 11 | newAdmin.storage.save(<- adminRef.createNewAdmin(), to: BloctoTokenStaking.StakingAdminStoragePath) 12 | } 13 | } 14 | // following tx can be executed, but not working when newAdmin using the capability 15 | // transaction() { 16 | // prepare(admin: auth(BorrowValue, Storage, Capabilities) &Account, newAdmin: auth(BorrowValue, Storage, Capabilities) &Account) { 17 | // let adminRef: &BloctoTokenStaking.Admin = admin.storage.borrow<&BloctoTokenStaking.Admin>(from: BloctoTokenStaking.StakingAdminStoragePath) 18 | // ?? panic("failed to borrow &BloctoTokenStaking.Admin") 19 | 20 | // // admin.capabilities.unpublish(/private/bloctoTokenStakingAdmin) 21 | // let adminCapability= admin.capabilities.storage.issue<&BloctoTokenStaking.Admin>( 22 | // BloctoTokenStaking.StakingAdminStoragePath 23 | // ) 24 | 25 | // let oldCapability = newAdmin.storage.load(from: BloctoTokenStaking.StakingAdminStoragePath) 26 | // newAdmin.storage.save(adminCapability, to: BloctoTokenStaking.StakingAdminStoragePath) 27 | 28 | // } 29 | // } 30 | -------------------------------------------------------------------------------- /transactions/staking/stakeNewTokens.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "BloctoPass" 4 | 5 | transaction(amount: UFix64) { 6 | 7 | // The Vault resource that holds the tokens that are being transferred 8 | let sentVault: @{FungibleToken.Vault} 9 | 10 | // The private reference to user's BloctoPass 11 | let bloctoPassRef: auth(BloctoPass.BloctoPassPrivateEntitlement) &BloctoPass.NFT 12 | 13 | prepare(signer: auth(BorrowValue) &Account) { 14 | 15 | // Get a reference to the signer's stored vault 16 | let vaultRef = signer.storage.borrow(from: BloctoToken.TokenStoragePath) 17 | ?? panic("Could not borrow reference to the owner's Vault!") 18 | 19 | // Withdraw tokens from the signer's stored vault 20 | self.sentVault <- vaultRef.withdraw(amount: amount) 21 | 22 | // Get a reference to the signer's BloctoPass 23 | let bloctoPassCollectionRef = signer.storage.borrow(from: /storage/bloctoPassCollection) 24 | ?? panic("Could not borrow reference to the owner's BloctoPass collection!") 25 | 26 | let ids = bloctoPassCollectionRef.getIDs() 27 | 28 | // Get a reference to the 29 | self.bloctoPassRef = bloctoPassCollectionRef.borrowBloctoPassPrivate(id: ids[0]) 30 | } 31 | 32 | execute { 33 | // Deposit BLT balance into BloctoPass first 34 | self.bloctoPassRef.deposit(from: <- self.sentVault) 35 | 36 | // Perform staking action 37 | self.bloctoPassRef.stakeNewTokens(amount: amount) 38 | } 39 | } -------------------------------------------------------------------------------- /transactions/staking/stakeNewTokensFromBloctoPass.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../contracts/flow/token/FungibleToken.cdc" 2 | import BloctoToken from "../../contracts/flow/token/BloctoToken.cdc" 3 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 4 | 5 | transaction(amount: UFix64) { 6 | 7 | // The private reference to user's BloctoPass 8 | let bloctoPassRef: &BloctoPass.NFT 9 | 10 | prepare(signer: AuthAccount) { 11 | 12 | // Get a reference to the signer's BloctoPass 13 | let bloctoPassCollectionRef = signer.borrow<&BloctoPass.Collection>(from: /storage/bloctoPassCollection) 14 | ?? panic("Could not borrow reference to the owner's BloctoPass collection!") 15 | 16 | let ids = bloctoPassCollectionRef.getIDs() 17 | 18 | // Get a reference to the 19 | self.bloctoPassRef = bloctoPassCollectionRef.borrowBloctoPassPrivate(id: ids[0]) 20 | } 21 | 22 | execute { 23 | // Perform staking action 24 | self.bloctoPassRef.stakeNewTokens(amount: amount) 25 | } 26 | } -------------------------------------------------------------------------------- /transactions/staking/switchEpoch.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoTokenStaking" 2 | 3 | // This transaction effectively ends the epoch and starts a new one. 4 | // 5 | // It combines the end_staking and move_tokens transactions 6 | // which ends the staking auction, which refunds nodes with insufficient stake 7 | // and moves tokens between buckets 8 | 9 | transaction(list: [UInt64]) { 10 | 11 | // Local variable for a reference to the ID Table Admin object 12 | let adminRef: auth(BloctoTokenStaking.AdminEntitlement) &BloctoTokenStaking.Admin 13 | 14 | prepare(acct: auth(BorrowValue) &Account) { 15 | // borrow a reference to the admin object 16 | self.adminRef = acct.storage.borrow(from: BloctoTokenStaking.StakingAdminStoragePath) 17 | ?? panic("Could not borrow reference to staking admin") 18 | } 19 | 20 | execute { 21 | self.adminRef.endStakingAuction() 22 | self.adminRef.payRewards(list) 23 | self.adminRef.moveTokens(list) 24 | self.adminRef.startStakingAuction() 25 | self.adminRef.startNewEpoch() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /transactions/swap/README.md: -------------------------------------------------------------------------------- 1 | # Swap 2 | ### Freeze Swap Pair 3 | ``` 4 | flow transactions send ./transactions/swap/freeze.cdc \ 5 | --network testnet \ 6 | --signer blt-swap-testnet \ 7 | --gas-limit 1000 8 | ``` 9 | 10 | ### Unfreeze Swap Pair 11 | ``` 12 | flow transactions send ./transactions/swap/unfreeze.cdc \ 13 | --network testnet \ 14 | --signer blt-swap-testnet \ 15 | --gas-limit 1000 16 | ``` 17 | 18 | ### Add Initial Liquidity 19 | ``` 20 | flow transactions send ./transactions/swap/addLiquidityByAdmin.cdc \ 21 | --network testnet \ 22 | --arg UFix64:10000.0 \ 23 | --arg UFix64:10000.0 \ 24 | --signer blt-swap-testnet \ 25 | --gas-limit 1000 26 | ``` 27 | 28 | ### Setup Swap Proxy 29 | ``` 30 | flow transactions build ./transactions/swap/setupSwapProxy.cdc \ 31 | --network mainnet \ 32 | --proposer 0xfcb06a5ae5b21a2d \ 33 | --proposer-key-index 0 \ 34 | --authorizer 0xfcb06a5ae5b21a2d \ 35 | --authorizer 0x55ad22f01ef568a1 \ 36 | --payer 0x55ad22f01ef568a1 \ 37 | --gas-limit 1000 \ 38 | -x payload \ 39 | --save ./build/unsigned.rlp 40 | 41 | flow transactions sign ./build/unsigned.rlp \ 42 | --signer blt-swap-admin-mainnet \ 43 | --filter payload \ 44 | --save ./build/signed-1.rlp 45 | 46 | flow transactions sign ./build/signed-1.rlp \ 47 | --signer blocto-hot-wallet-mainnet \ 48 | --filter payload \ 49 | --save ./build/signed-2.rlp 50 | 51 | flow transactions send-signed --network mainnet ./build/signed-2.rlp 52 | ``` 53 | -------------------------------------------------------------------------------- /transactions/swap/addLiquidityByAdmin.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../contracts/flow/token/FungibleToken.cdc" 2 | import BloctoToken from "../../contracts/flow/token/BloctoToken.cdc" 3 | import TeleportedTetherToken from "../../contracts/flow/token/TeleportedTetherToken.cdc" 4 | import BltUsdtSwapPair from "../../contracts/flow/swap/BltUsdtSwapPair.cdc" 5 | 6 | transaction(token1Amount: UFix64, token2Amount: UFix64) { 7 | prepare(signer: AuthAccount) { 8 | let bltVault = signer.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 9 | ?? panic("Could not borrow a reference to Vault") 10 | 11 | let token1Vault <- bltVault.withdraw(amount: token1Amount) as! @BloctoToken.Vault 12 | 13 | let tetherVault = signer.borrow<&TeleportedTetherToken.Vault>(from: TeleportedTetherToken.TokenStoragePath) 14 | ?? panic("Could not borrow a reference to Vault") 15 | 16 | let token2Vault <- tetherVault.withdraw(amount: token2Amount) as! @TeleportedTetherToken.Vault 17 | 18 | let adminRef = signer.borrow<&BltUsdtSwapPair.Admin>(from: /storage/bltUsdtPairAdmin) 19 | ?? panic("Could not borrow a reference to Admin") 20 | 21 | let tokenBundle <- BltUsdtSwapPair.createTokenBundle(fromToken1: <- token1Vault, fromToken2: <- token2Vault); 22 | let liquidityTokenVault <- adminRef.addInitialLiquidity(from: <- tokenBundle) 23 | 24 | if signer.borrow<&BltUsdtSwapPair.Vault>(from: BltUsdtSwapPair.TokenStoragePath) == nil { 25 | // Create a new swap LP token Vault and put it in storage 26 | signer.save(<-BltUsdtSwapPair.createEmptyVault(), to: BltUsdtSwapPair.TokenStoragePath) 27 | 28 | // Create a public capability to the Vault that only exposes 29 | // the deposit function through the Receiver interface 30 | signer.link<&BltUsdtSwapPair.Vault{FungibleToken.Receiver}>( 31 | BltUsdtSwapPair.TokenPublicReceiverPath, 32 | target: BltUsdtSwapPair.TokenStoragePath 33 | ) 34 | 35 | // Create a public capability to the Vault that only exposes 36 | // the balance field through the Balance interface 37 | signer.link<&BltUsdtSwapPair.Vault{FungibleToken.Balance}>( 38 | BltUsdtSwapPair.TokenPublicBalancePath, 39 | target: BltUsdtSwapPair.TokenStoragePath 40 | ) 41 | } 42 | 43 | let liquidityTokenRef = signer.borrow<&BltUsdtSwapPair.Vault>(from: BltUsdtSwapPair.TokenStoragePath) 44 | ?? panic("Could not borrow a reference to Vault") 45 | 46 | liquidityTokenRef.deposit(from: <- liquidityTokenVault) 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /transactions/swap/freeze.cdc: -------------------------------------------------------------------------------- 1 | import BltUsdtSwapPair from "../../contracts/flow/swap/BltUsdtSwapPair.cdc" 2 | 3 | transaction() { 4 | prepare(swapPairAdmin: AuthAccount) { 5 | 6 | let adminRef = swapPairAdmin.borrow<&BltUsdtSwapPair.Admin>(from: /storage/bltUsdtPairAdmin) 7 | ?? panic("Could not borrow a reference to Admin") 8 | 9 | adminRef.freeze() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/swap/setupSwapProxy.cdc: -------------------------------------------------------------------------------- 1 | import BltUsdtSwapPair from "../../contracts/flow/swap/BltUsdtSwapPair.cdc" 2 | 3 | transaction { 4 | let proxy: @BltUsdtSwapPair.SwapProxy 5 | let holder: AuthAccount 6 | 7 | prepare(swapContractAccount: AuthAccount, proxyHolder: AuthAccount) { 8 | let adminRef = swapContractAccount.borrow<&BltUsdtSwapPair.Admin>(from: /storage/bltUsdtPairAdmin) 9 | ?? panic("Could not borrow a reference to Admin") 10 | 11 | self.proxy <- adminRef.createSwapProxy() 12 | 13 | assert(self.proxy != nil, message: "loaded proxy resource is nil") 14 | 15 | self.holder = proxyHolder 16 | } 17 | 18 | execute { 19 | self.holder.save(<-self.proxy, to: /storage/bltUsdtSwapProxy) 20 | 21 | let newSwapProxyRef = self.holder 22 | .borrow<&BltUsdtSwapPair.SwapProxy>(from: /storage/bltUsdtSwapProxy) 23 | ?? panic("Could not borrow a reference to new proxy holder") 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /transactions/swap/unfreeze.cdc: -------------------------------------------------------------------------------- 1 | import BltUsdtSwapPair from "../../contracts/flow/swap/BltUsdtSwapPair.cdc" 2 | 3 | transaction() { 4 | prepare(swapPairAdmin: AuthAccount) { 5 | 6 | let adminRef = swapPairAdmin.borrow<&BltUsdtSwapPair.Admin>(from: /storage/bltUsdtPairAdmin) 7 | ?? panic("Could not borrow a reference to Admin") 8 | 9 | adminRef.unfreeze() 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/teleport/Aptos/collectFeeAptos.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportCustodyAptos" 3 | import "BloctoToken" 4 | 5 | transaction(to: Address) { 6 | prepare(signer: auth(BorrowValue) &Account) { 7 | let adminRef = signer.storage.borrow(from: TeleportCustodyAptos.TeleportAdminStoragePath) 8 | ?? panic("Could not borrow a reference to the admin resource") 9 | 10 | let feeAmount = adminRef.getFeeAmount(); 11 | let vault <- adminRef.withdrawFee(amount: feeAmount); 12 | 13 | // Get the recipient's public account object 14 | let recipient = getAccount(to) 15 | 16 | // Get a reference to the recipient's Receiver 17 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 18 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 19 | 20 | // Deposit the withdrawn tokens in the recipient's receiver 21 | receiverRef.deposit(from: <-vault) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /transactions/teleport/Aptos/createTeleportAdminAptos.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyAptos" 2 | 3 | transaction(allowedAmount: UFix64) { 4 | 5 | prepare(admin: auth(BorrowValue) &Account, teleportAdmin: auth(SaveValue, Capabilities) &Account) { 6 | let adminRef = admin.storage.borrow(from: TeleportCustodyAptos.AdminStoragePath) 7 | ?? panic("Could not borrow a reference to the admin resource") 8 | 9 | let teleportAdminResource <- adminRef.createNewTeleportAdmin(allowedAmount: allowedAmount) 10 | 11 | teleportAdmin.storage.save(<- teleportAdminResource, to: TeleportCustodyAptos.TeleportAdminStoragePath) 12 | 13 | let cap = teleportAdmin.capabilities.unpublish(TeleportCustodyAptos.TeleportAdminTeleportUserPath) 14 | 15 | let teleportUserCap = teleportAdmin.capabilities.storage.issue<&{TeleportCustodyAptos.TeleportUser}>(TeleportCustodyAptos.TeleportAdminStoragePath) 16 | teleportAdmin.capabilities.publish(teleportUserCap, at: TeleportCustodyAptos.TeleportAdminTeleportUserPath) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/teleport/Aptos/depositAllowanceAptos.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyAptos" 2 | 3 | transaction(teleportAdmin: Address, allowedAmount: UFix64) { 4 | prepare(admin: auth(BorrowValue) &Account) { 5 | 6 | let adminRef = admin.storage.borrow(from: TeleportCustodyAptos.AdminStoragePath) 7 | ?? panic("Could not borrow a reference to the admin resource") 8 | 9 | let allowance <- adminRef.createAllowance(allowedAmount: allowedAmount) 10 | 11 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyAptos.TeleportUser}>(TeleportCustodyAptos.TeleportAdminTeleportUserPath) 12 | ?? panic("Could not borrow a reference to TeleportUser") 13 | 14 | teleportUserRef.depositAllowance(from: <- allowance) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /transactions/teleport/Aptos/lockTokensAptos.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodyAptos" 4 | 5 | transaction(admin: Address, amount: UFix64, target: String) { 6 | 7 | // The TeleportUser reference for teleport operations 8 | let teleportUserRef: &{TeleportCustodyAptos.TeleportUser} 9 | 10 | // The Vault resource that holds the tokens that are being transferred 11 | let sentVault: @{FungibleToken.Vault} 12 | 13 | prepare(signer: auth(BorrowValue) &Account) { 14 | self.teleportUserRef = getAccount(admin).capabilities.borrow<&{TeleportCustodyAptos.TeleportUser}>(TeleportCustodyAptos.TeleportAdminTeleportUserPath) 15 | ?? panic("Could not borrow a reference to TeleportOut") 16 | 17 | let vaultRef = signer.storage.borrow(from: BloctoToken.TokenStoragePath) 18 | ?? panic("Could not borrow a reference to the vault resource") 19 | // panic(vaultRef.balance.toString().concat(" ").concat(amount.toString())) 20 | self.sentVault <- vaultRef.withdraw(amount: amount) 21 | } 22 | 23 | execute { 24 | self.teleportUserRef.lock(from: <- self.sentVault, to: target.decodeHex()) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /transactions/teleport/Aptos/transferTeleportFeesAptos.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodyAptos" 4 | 5 | transaction(target: Address) { 6 | // The teleport admin reference 7 | let teleportAdminRef: auth(TeleportCustodyAptos.AdminEntitlement) &TeleportCustodyAptos.TeleportAdmin 8 | 9 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 10 | self.teleportAdminRef = teleportAdmin.storage.borrow(from: TeleportCustodyAptos.TeleportAdminStoragePath) 11 | ?? panic("Could not borrow a reference to the teleport admin resource") 12 | } 13 | 14 | execute { 15 | let feeVault <- self.teleportAdminRef.withdrawFee(amount: self.teleportAdminRef.getFeeAmount()) 16 | 17 | // Get the recipient's public account object 18 | let recipient = getAccount(target) 19 | 20 | // Get a reference to the recipient's Receiver 21 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 22 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 23 | 24 | // Deposit the withdrawn tokens in the recipient's receiver 25 | receiverRef.deposit(from: <- feeVault) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /transactions/teleport/Aptos/unlockTokensAptos.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodyAptos" 4 | 5 | transaction(amount: UFix64, target: Address, from: String, hash: String) { 6 | 7 | // The TeleportControl reference for teleport operations 8 | let teleportControlRef: auth(TeleportCustodyAptos.AdminEntitlement) &{TeleportCustodyAptos.TeleportControl} 9 | 10 | // The Receiver reference of the user 11 | let receiverRef: &{FungibleToken.Receiver} 12 | 13 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 14 | self.teleportControlRef = teleportAdmin.storage.borrow(from: TeleportCustodyAptos.TeleportAdminStoragePath) 15 | ?? panic("Could not borrow a reference to TeleportControl") 16 | 17 | self.receiverRef = getAccount(target).capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 18 | ?? panic("Could not borrow a reference to Receiver") 19 | } 20 | 21 | execute { 22 | let vault <- self.teleportControlRef.unlock(amount: amount, from: from.decodeHex(), txHash: hash) 23 | 24 | self.receiverRef.deposit(from: <- vault) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /transactions/teleport/Aptos/updateTeleportFeesAptos.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyAptos" 2 | 3 | transaction(lockFee: UFix64, unlockFee: UFix64) { 4 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 5 | let teleportAdminRef = teleportAdmin.storage.borrow(from: TeleportCustodyAptos.TeleportAdminStoragePath) 6 | ?? panic("Could not borrow a reference to the teleport admin resource") 7 | 8 | teleportAdminRef.updateLockFee(fee: lockFee) 9 | teleportAdminRef.updateUnlockFee(fee: unlockFee) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/teleport/BSC/collectFeeBSC.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportCustodyBSC" 3 | import "BloctoToken" 4 | 5 | transaction(to: Address) { 6 | prepare(signer: auth(BorrowValue) &Account) { 7 | let adminRef = signer.storage.borrow(from: TeleportCustodyBSC.TeleportAdminStoragePath) 8 | ?? panic("Could not borrow a reference to the admin resource") 9 | 10 | let feeAmount = adminRef.getFeeAmount(); 11 | let vault <- adminRef.withdrawFee(amount: feeAmount); 12 | 13 | // Get the recipient's public account object 14 | let recipient = getAccount(to) 15 | 16 | // Get a reference to the recipient's Receiver 17 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 18 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 19 | 20 | // Deposit the withdrawn tokens in the recipient's receiver 21 | receiverRef.deposit(from: <-vault) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /transactions/teleport/BSC/createTeleportAdminBSC.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyBSC" 2 | 3 | transaction(allowedAmount: UFix64) { 4 | 5 | prepare(admin: auth(BorrowValue) &Account, teleportAdmin: auth(SaveValue, Capabilities) &Account) { 6 | let adminRef = admin.storage.borrow(from: TeleportCustodyBSC.AdminStoragePath) 7 | ?? panic("Could not borrow a reference to the admin resource") 8 | 9 | let teleportAdminResource <- adminRef.createNewTeleportAdmin(allowedAmount: allowedAmount) 10 | 11 | teleportAdmin.storage.save(<- teleportAdminResource, to: TeleportCustodyBSC.TeleportAdminStoragePath) 12 | 13 | let cap = teleportAdmin.capabilities.unpublish(TeleportCustodyBSC.TeleportAdminTeleportUserPath) 14 | 15 | let teleportUserCap = teleportAdmin.capabilities.storage.issue<&{TeleportCustodyBSC.TeleportUser}>(TeleportCustodyBSC.TeleportAdminStoragePath) 16 | teleportAdmin.capabilities.publish(teleportUserCap, at: TeleportCustodyBSC.TeleportAdminTeleportUserPath) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/teleport/BSC/depositAllowanceBSC.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyBSC" 2 | 3 | transaction(teleportAdmin: Address, allowedAmount: UFix64) { 4 | prepare(admin: auth(BorrowValue) &Account) { 5 | 6 | let adminRef = admin.storage.borrow(from: TeleportCustodyBSC.AdminStoragePath) 7 | ?? panic("Could not borrow a reference to the admin resource") 8 | 9 | let allowance <- adminRef.createAllowance(allowedAmount: allowedAmount) 10 | 11 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyBSC.TeleportUser}>(TeleportCustodyBSC.TeleportAdminTeleportUserPath) 12 | ?? panic("Could not borrow a reference to TeleportUser") 13 | 14 | teleportUserRef.depositAllowance(from: <- allowance) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /transactions/teleport/BSC/lockTokensBSC.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodyBSC" 4 | 5 | transaction(admin: Address, amount: UFix64, target: String) { 6 | 7 | // The TeleportUser reference for teleport operations 8 | let teleportUserRef: &{TeleportCustodyBSC.TeleportUser} 9 | 10 | // The Vault resource that holds the tokens that are being transferred 11 | let sentVault: @{FungibleToken.Vault} 12 | 13 | prepare(signer: auth(BorrowValue) &Account) { 14 | self.teleportUserRef = getAccount(admin).capabilities.borrow<&{TeleportCustodyBSC.TeleportUser}>(TeleportCustodyBSC.TeleportAdminTeleportUserPath) 15 | ?? panic("Could not borrow a reference to TeleportOut") 16 | 17 | let vaultRef = signer.storage.borrow(from: BloctoToken.TokenStoragePath) 18 | ?? panic("Could not borrow a reference to the vault resource") 19 | // panic(vaultRef.balance.toString().concat(" ").concat(amount.toString())) 20 | self.sentVault <- vaultRef.withdraw(amount: amount) 21 | } 22 | 23 | execute { 24 | self.teleportUserRef.lock(from: <- self.sentVault, to: target.decodeHex()) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /transactions/teleport/BSC/transferTeleportFeesBSC.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodyBSC" 4 | 5 | transaction(target: Address) { 6 | // The teleport admin reference 7 | let teleportAdminRef: auth(TeleportCustodyBSC.AdminEntitlement) &TeleportCustodyBSC.TeleportAdmin 8 | 9 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 10 | self.teleportAdminRef = teleportAdmin.storage.borrow(from: TeleportCustodyBSC.TeleportAdminStoragePath) 11 | ?? panic("Could not borrow a reference to the teleport admin resource") 12 | } 13 | 14 | execute { 15 | let feeVault <- self.teleportAdminRef.withdrawFee(amount: self.teleportAdminRef.getFeeAmount()) 16 | 17 | // Get the recipient's public account object 18 | let recipient = getAccount(target) 19 | 20 | // Get a reference to the recipient's Receiver 21 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 22 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 23 | 24 | // Deposit the withdrawn tokens in the recipient's receiver 25 | receiverRef.deposit(from: <- feeVault) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /transactions/teleport/BSC/unlockTokensBSC.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodyBSC" 4 | 5 | transaction(amount: UFix64, target: Address, from: String, hash: String) { 6 | 7 | // The TeleportControl reference for teleport operations 8 | let teleportControlRef: auth(TeleportCustodyBSC.AdminEntitlement) &{TeleportCustodyBSC.TeleportControl} 9 | 10 | // The Receiver reference of the user 11 | let receiverRef: &{FungibleToken.Receiver} 12 | 13 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 14 | self.teleportControlRef = teleportAdmin.storage.borrow(from: TeleportCustodyBSC.TeleportAdminStoragePath) 15 | ?? panic("Could not borrow a reference to TeleportControl") 16 | 17 | self.receiverRef = getAccount(target).capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 18 | ?? panic("Could not borrow a reference to Receiver") 19 | } 20 | 21 | execute { 22 | let vault <- self.teleportControlRef.unlock(amount: amount, from: from.decodeHex(), txHash: hash) 23 | 24 | self.receiverRef.deposit(from: <- vault) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /transactions/teleport/BSC/updateTeleportFeesBSC.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyBSC" 2 | 3 | transaction(lockFee: UFix64, unlockFee: UFix64) { 4 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 5 | let teleportAdminRef = teleportAdmin.storage.borrow(from: TeleportCustodyBSC.TeleportAdminStoragePath) 6 | ?? panic("Could not borrow a reference to the teleport admin resource") 7 | 8 | teleportAdminRef.updateLockFee(fee: lockFee) 9 | teleportAdminRef.updateUnlockFee(fee: unlockFee) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/teleport/Ethereum/collectFeeEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportCustodyEthereum" 3 | import "BloctoToken" 4 | 5 | transaction(to: Address) { 6 | prepare(signer: auth(BorrowValue) &Account) { 7 | let adminRef = signer.storage.borrow(from: TeleportCustodyEthereum.TeleportAdminStoragePath) 8 | ?? panic("Could not borrow a reference to the admin resource") 9 | 10 | let feeAmount = adminRef.getFeeAmount(); 11 | let vault <- adminRef.withdrawFee(amount: feeAmount); 12 | 13 | // Get the recipient's public account object 14 | let recipient = getAccount(to) 15 | 16 | // Get a reference to the recipient's Receiver 17 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 18 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 19 | 20 | // Deposit the withdrawn tokens in the recipient's receiver 21 | receiverRef.deposit(from: <-vault) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /transactions/teleport/Ethereum/createTeleportAdminEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyEthereum" 2 | 3 | transaction(allowedAmount: UFix64) { 4 | 5 | prepare(admin: auth(BorrowValue) &Account, teleportAdmin: auth(SaveValue, Capabilities) &Account) { 6 | let adminRef = admin.storage.borrow(from: TeleportCustodyEthereum.AdminStoragePath) 7 | ?? panic("Could not borrow a reference to the admin resource") 8 | 9 | let teleportAdminResource <- adminRef.createNewTeleportAdmin(allowedAmount: allowedAmount) 10 | 11 | teleportAdmin.storage.save(<- teleportAdminResource, to: TeleportCustodyEthereum.TeleportAdminStoragePath) 12 | 13 | let cap = teleportAdmin.capabilities.unpublish(TeleportCustodyEthereum.TeleportAdminTeleportUserPath) 14 | 15 | let teleportUserCap = teleportAdmin.capabilities.storage.issue<&{TeleportCustodyEthereum.TeleportUser}>(TeleportCustodyEthereum.TeleportAdminStoragePath) 16 | teleportAdmin.capabilities.publish(teleportUserCap, at: TeleportCustodyEthereum.TeleportAdminTeleportUserPath) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/teleport/Ethereum/depositAllowanceEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyEthereum" 2 | 3 | transaction(teleportAdmin: Address, allowedAmount: UFix64) { 4 | prepare(admin: auth(BorrowValue) &Account) { 5 | 6 | let adminRef = admin.storage.borrow(from: TeleportCustodyEthereum.AdminStoragePath) 7 | ?? panic("Could not borrow a reference to the admin resource") 8 | 9 | let allowance <- adminRef.createAllowance(allowedAmount: allowedAmount) 10 | 11 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodyEthereum.TeleportUser}>(TeleportCustodyEthereum.TeleportAdminTeleportUserPath) 12 | ?? panic("Could not borrow a reference to TeleportUser") 13 | 14 | teleportUserRef.depositAllowance(from: <- allowance) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /transactions/teleport/Ethereum/lockTokensEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodyEthereum" 4 | 5 | transaction(admin: Address, amount: UFix64, target: String) { 6 | 7 | // The TeleportUser reference for teleport operations 8 | let teleportUserRef: &{TeleportCustodyEthereum.TeleportUser} 9 | 10 | // The Vault resource that holds the tokens that are being transferred 11 | let sentVault: @{FungibleToken.Vault} 12 | 13 | prepare(signer: auth(BorrowValue) &Account) { 14 | self.teleportUserRef = getAccount(admin).capabilities.borrow<&{TeleportCustodyEthereum.TeleportUser}>(TeleportCustodyEthereum.TeleportAdminTeleportUserPath) 15 | ?? panic("Could not borrow a reference to TeleportOut") 16 | 17 | let vaultRef = signer.storage.borrow(from: BloctoToken.TokenStoragePath) 18 | ?? panic("Could not borrow a reference to the vault resource") 19 | // panic(vaultRef.balance.toString().concat(" ").concat(amount.toString())) 20 | self.sentVault <- vaultRef.withdraw(amount: amount) 21 | } 22 | 23 | execute { 24 | self.teleportUserRef.lock(from: <- self.sentVault, to: target.decodeHex()) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /transactions/teleport/Ethereum/storageTestForMigration.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyEthereum" 2 | import "BloctoToken" 3 | import "FungibleToken" 4 | 5 | transaction(allowedAmount: UFix64, ethereumAddress: String, txHash: String) { 6 | 7 | prepare(admin: auth(BorrowValue) &Account, teleportAdmin: auth(Storage, Capabilities) &Account, signer: auth(Storage, Capabilities) &Account) { 8 | 9 | // mint new blocto token 10 | let bloctoTokenAdmin = admin.storage 11 | .borrow(from: /storage/bloctoTokenAdmin) 12 | ?? panic("Signer is not the admin") 13 | 14 | let minter <- bloctoTokenAdmin.createNewMinter(allowedAmount: allowedAmount) 15 | 16 | let mintedAmount = allowedAmount 17 | 18 | let receiver = signer.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 19 | ?? panic("Could not borrow a reference to the receiver") 20 | 21 | receiver.deposit(from: <- minter.mintTokens(amount: mintedAmount)) 22 | 23 | destroy minter 24 | 25 | // setup teleport admin 26 | 27 | let adminRef = admin.storage.borrow(from: TeleportCustodyEthereum.AdminStoragePath) 28 | ?? panic("Could not borrow a reference to the admin resource") 29 | 30 | let teleportAdmin = teleportAdmin.storage.borrow(from: TeleportCustodyEthereum.TeleportAdminStoragePath) 31 | ?? panic("Could not borrow a reference to TeleportUser") 32 | 33 | let allowance <- adminRef.createAllowance(allowedAmount: teleportAdmin.allowedAmount) 34 | 35 | teleportAdmin.depositAllowance(from: <- allowance) 36 | 37 | // lock tokens 38 | 39 | let vaultRef = signer.storage.borrow(from: BloctoToken.TokenStoragePath) 40 | ?? panic("Could not borrow a reference to the vault resource") 41 | // panic(vaultRef.balance.toString().concat(" ").concat(amount.toString())) 42 | let amount = vaultRef.balance / 2.0 43 | let sentVault <- vaultRef.withdraw(amount: amount) 44 | 45 | teleportAdmin.lock(from: <- sentVault, to: ethereumAddress.decodeHex()) 46 | 47 | // unlock tokens 48 | 49 | let vault <- teleportAdmin.unlock(amount: amount / 2.0, from: ethereumAddress.decodeHex(), txHash: txHash) 50 | 51 | receiver.deposit(from: <- vault) 52 | 53 | // update teleport fees 54 | 55 | teleportAdmin.updateLockFee(fee: 0.3) 56 | teleportAdmin.updateUnlockFee(fee: 0.11) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /transactions/teleport/Ethereum/transferTeleportFeesEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodyEthereum" 4 | 5 | transaction(target: Address) { 6 | // The teleport admin reference 7 | let teleportAdminRef: auth(TeleportCustodyEthereum.AdminEntitlement) &TeleportCustodyEthereum.TeleportAdmin 8 | 9 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 10 | self.teleportAdminRef = teleportAdmin.storage.borrow(from: TeleportCustodyEthereum.TeleportAdminStoragePath) 11 | ?? panic("Could not borrow a reference to the teleport admin resource") 12 | } 13 | 14 | execute { 15 | let feeVault <- self.teleportAdminRef.withdrawFee(amount: self.teleportAdminRef.getFeeAmount()) 16 | 17 | // Get the recipient's public account object 18 | let recipient = getAccount(target) 19 | 20 | // Get a reference to the recipient's Receiver 21 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 22 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 23 | 24 | // Deposit the withdrawn tokens in the recipient's receiver 25 | receiverRef.deposit(from: <- feeVault) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /transactions/teleport/Ethereum/unlockTokensEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodyEthereum" 4 | 5 | transaction(amount: UFix64, target: Address, from: String, hash: String) { 6 | 7 | // The TeleportControl reference for teleport operations 8 | let teleportControlRef: auth(TeleportCustodyEthereum.AdminEntitlement) &{TeleportCustodyEthereum.TeleportControl} 9 | 10 | // The Receiver reference of the user 11 | let receiverRef: &{FungibleToken.Receiver} 12 | 13 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 14 | self.teleportControlRef = teleportAdmin.storage.borrow(from: TeleportCustodyEthereum.TeleportAdminStoragePath) 15 | ?? panic("Could not borrow a reference to TeleportControl") 16 | 17 | self.receiverRef = getAccount(target).capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 18 | ?? panic("Could not borrow a reference to Receiver") 19 | } 20 | 21 | execute { 22 | let vault <- self.teleportControlRef.unlock(amount: amount, from: from.decodeHex(), txHash: hash) 23 | 24 | self.receiverRef.deposit(from: <- vault) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /transactions/teleport/Ethereum/updateTeleportFeesEthereum.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodyEthereum" 2 | 3 | transaction(lockFee: UFix64, unlockFee: UFix64) { 4 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 5 | let teleportAdminRef = teleportAdmin.storage.borrow(from: TeleportCustodyEthereum.TeleportAdminStoragePath) 6 | ?? panic("Could not borrow a reference to the teleport admin resource") 7 | 8 | teleportAdminRef.updateLockFee(fee: lockFee) 9 | teleportAdminRef.updateUnlockFee(fee: unlockFee) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/teleport/Solana/collectFeeSolana.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportCustodySolana" 3 | import "BloctoToken" 4 | 5 | transaction(to: Address) { 6 | prepare(signer: auth(BorrowValue) &Account) { 7 | let adminRef = signer.storage.borrow(from: TeleportCustodySolana.TeleportAdminStoragePath) 8 | ?? panic("Could not borrow a reference to the admin resource") 9 | 10 | let feeAmount = adminRef.getFeeAmount(); 11 | let vault <- adminRef.withdrawFee(amount: feeAmount); 12 | 13 | // Get the recipient's public account object 14 | let recipient = getAccount(to) 15 | 16 | // Get a reference to the recipient's Receiver 17 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 18 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 19 | 20 | // Deposit the withdrawn tokens in the recipient's receiver 21 | receiverRef.deposit(from: <-vault) 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /transactions/teleport/Solana/createTeleportAdminSolana.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodySolana" 2 | 3 | transaction(allowedAmount: UFix64) { 4 | 5 | prepare(admin: auth(BorrowValue) &Account, teleportAdmin: auth(SaveValue, Capabilities) &Account) { 6 | let adminRef = admin.storage.borrow(from: TeleportCustodySolana.AdminStoragePath) 7 | ?? panic("Could not borrow a reference to the admin resource") 8 | 9 | let teleportAdminResource <- adminRef.createNewTeleportAdmin(allowedAmount: allowedAmount) 10 | 11 | teleportAdmin.storage.save(<- teleportAdminResource, to: TeleportCustodySolana.TeleportAdminStoragePath) 12 | 13 | let cap = teleportAdmin.capabilities.unpublish(TeleportCustodySolana.TeleportAdminTeleportUserPath) 14 | 15 | let teleportUserCap = teleportAdmin.capabilities.storage.issue<&{TeleportCustodySolana.TeleportUser}>(TeleportCustodySolana.TeleportAdminStoragePath) 16 | teleportAdmin.capabilities.publish(teleportUserCap, at: TeleportCustodySolana.TeleportAdminTeleportUserPath) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/teleport/Solana/depositAllowanceSolana.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodySolana" 2 | 3 | transaction(teleportAdmin: Address, allowedAmount: UFix64) { 4 | prepare(admin: auth(BorrowValue) &Account) { 5 | 6 | let adminRef = admin.storage.borrow(from: TeleportCustodySolana.AdminStoragePath) 7 | ?? panic("Could not borrow a reference to the admin resource") 8 | 9 | let allowance <- adminRef.createAllowance(allowedAmount: allowedAmount) 10 | 11 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportCustodySolana.TeleportUser}>(TeleportCustodySolana.TeleportAdminTeleportUserPath) 12 | ?? panic("Could not borrow a reference to TeleportUser") 13 | 14 | teleportUserRef.depositAllowance(from: <- allowance) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /transactions/teleport/Solana/lockTokensSolana.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodySolana" 4 | 5 | transaction(admin: Address, amount: UFix64, target: String, toAddressType: String) { 6 | 7 | // The TeleportUser reference for teleport operations 8 | let teleportUserRef: &{TeleportCustodySolana.TeleportUser} 9 | 10 | // The Vault resource that holds the tokens that are being transferred 11 | let sentVault: @{FungibleToken.Vault} 12 | 13 | prepare(signer: auth(BorrowValue) &Account) { 14 | self.teleportUserRef = getAccount(admin).capabilities.borrow<&{TeleportCustodySolana.TeleportUser}>(TeleportCustodySolana.TeleportAdminTeleportUserPath) 15 | ?? panic("Could not borrow a reference to TeleportOut") 16 | 17 | let vaultRef = signer.storage.borrow(from: BloctoToken.TokenStoragePath) 18 | ?? panic("Could not borrow a reference to the vault resource") 19 | 20 | self.sentVault <- vaultRef.withdraw(amount: amount) 21 | } 22 | 23 | execute { 24 | self.teleportUserRef.lock(from: <- self.sentVault, to: target.decodeHex(), toAddressType: toAddressType) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /transactions/teleport/Solana/transferTeleportFeesSolana.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodySolana" 4 | 5 | transaction(target: Address) { 6 | // The teleport admin reference 7 | let teleportAdminRef: auth(TeleportCustodySolana.AdminEntitlement) &TeleportCustodySolana.TeleportAdmin 8 | 9 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 10 | self.teleportAdminRef = teleportAdmin.storage.borrow(from: TeleportCustodySolana.TeleportAdminStoragePath) 11 | ?? panic("Could not borrow a reference to the teleport admin resource") 12 | } 13 | 14 | execute { 15 | let feeVault <- self.teleportAdminRef.withdrawFee(amount: self.teleportAdminRef.getFeeAmount()) 16 | 17 | // Get the recipient's public account object 18 | let recipient = getAccount(target) 19 | 20 | // Get a reference to the recipient's Receiver 21 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 22 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 23 | 24 | // Deposit the withdrawn tokens in the recipient's receiver 25 | receiverRef.deposit(from: <- feeVault) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /transactions/teleport/Solana/unlockTokensSolana.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodySolana" 4 | 5 | transaction(amount: UFix64, target: Address, from: String, hash: String) { 6 | 7 | // The TeleportControl reference for teleport operations 8 | let teleportControlRef: auth(TeleportCustodySolana.AdminEntitlement) &{TeleportCustodySolana.TeleportControl} 9 | 10 | // The Receiver reference of the user 11 | let receiverRef: &{FungibleToken.Receiver} 12 | 13 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 14 | self.teleportControlRef = teleportAdmin.storage.borrow(from: TeleportCustodySolana.TeleportAdminStoragePath) 15 | ?? panic("Could not borrow a reference to TeleportControl") 16 | 17 | self.receiverRef = getAccount(target).capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 18 | ?? panic("Could not borrow a reference to Receiver") 19 | } 20 | 21 | execute { 22 | let vault <- self.teleportControlRef.unlock(amount: amount, from: from.decodeHex(), txHash: hash) 23 | 24 | self.receiverRef.deposit(from: <- vault) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /transactions/teleport/Solana/updateTeleportFeesSolana.cdc: -------------------------------------------------------------------------------- 1 | import "TeleportCustodySolana" 2 | 3 | transaction(lockFee: UFix64, unlockFee: UFix64) { 4 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 5 | let teleportAdminRef = teleportAdmin.storage.borrow(from: TeleportCustodySolana.TeleportAdminStoragePath) 6 | ?? panic("Could not borrow a reference to the teleport admin resource") 7 | 8 | teleportAdminRef.updateLockFee(fee: lockFee) 9 | teleportAdminRef.updateUnlockFee(fee: unlockFee) 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /transactions/teleport/burnTokensSolana.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "TeleportCustodySolana" 4 | 5 | transaction(amount: UFix64, from: String, hash: String) { 6 | 7 | // The TeleportControl reference for teleport operations 8 | let teleportControlRef: auth(TeleportCustodySolana.AdminEntitlement) &{TeleportCustodySolana.TeleportControl} 9 | 10 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 11 | self.teleportControlRef = teleportAdmin.storage.borrow(from: TeleportCustodySolana.TeleportAdminStoragePath) 12 | ?? panic("Could not borrow a reference to TeleportControl") 13 | } 14 | 15 | execute { 16 | self.teleportControlRef.updateUnlockFee(fee: 0.0) 17 | let vault <- self.teleportControlRef.unlock(amount: amount, from: from.decodeHex(), txHash: hash) 18 | self.teleportControlRef.updateUnlockFee(fee: 0.1) 19 | 20 | destroy vault 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /transactions/teleport/lockTokens.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import TeleportCustody from "../../contracts/flow/teleport/TeleportCustody.cdc" 4 | 5 | transaction(admin: Address, amount: UFix64, target: String) { 6 | 7 | // The TeleportUser reference for teleport operations 8 | let teleportUserRef: &TeleportCustody.TeleportAdmin{TeleportCustody.TeleportUser} 9 | 10 | // The Vault resource that holds the tokens that are being transferred 11 | let sentVault: @FungibleToken.Vault 12 | 13 | prepare(signer: AuthAccount) { 14 | self.teleportUserRef = getAccount(admin).getCapability(TeleportCustody.TeleportAdminTeleportUserPath) 15 | .borrow<&TeleportCustody.TeleportAdmin{TeleportCustody.TeleportUser}>() 16 | ?? panic("Could not borrow a reference to TeleportOut") 17 | 18 | let vaultRef = signer.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 19 | ?? panic("Could not borrow a reference to the vault resource") 20 | 21 | self.sentVault <- vaultRef.withdraw(amount: amount) 22 | } 23 | 24 | execute { 25 | self.teleportUserRef.lock(from: <- self.sentVault, to: target.decodeHex()) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /transactions/teleport/unlockTokens.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import TeleportCustody from "../../contracts/flow/teleport/TeleportCustody.cdc" 4 | 5 | transaction(amount: UFix64, target: Address, from: String, hash: String) { 6 | 7 | // The TeleportControl reference for teleport operations 8 | let teleportControlRef: &TeleportCustody.TeleportAdmin{TeleportCustody.TeleportControl} 9 | 10 | // The Receiver reference of the user 11 | let receiverRef: &BloctoToken.Vault{FungibleToken.Receiver} 12 | 13 | prepare(teleportAdmin: AuthAccount) { 14 | self.teleportControlRef = teleportAdmin.getCapability(TeleportCustody.TeleportAdminTeleportControlPath) 15 | .borrow<&TeleportCustody.TeleportAdmin{TeleportCustody.TeleportControl}>() 16 | ?? panic("Could not borrow a reference to TeleportControl") 17 | 18 | self.receiverRef = getAccount(target).getCapability(BloctoToken.TokenPublicReceiverPath) 19 | .borrow<&BloctoToken.Vault{FungibleToken.Receiver}>() 20 | ?? panic("Could not borrow a reference to Receiver") 21 | } 22 | 23 | execute { 24 | let vault <- self.teleportControlRef.unlock(amount: amount, from: from.decodeHex(), txHash: hash) 25 | 26 | self.receiverRef.deposit(from: <- vault) 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /transactions/token/README.md: -------------------------------------------------------------------------------- 1 | # Token 2 | ### Setup BloctoToken Vault 3 | ``` 4 | flow transactions send ./transactions/token/setupBloctoTokenVault.cdc \ 5 | --network testnet \ 6 | --signer blt-user-testnet \ 7 | --gas-limit 1000 8 | ``` 9 | 10 | ### Transfer BloctoToken 11 | ``` 12 | flow transactions send ./transactions/token/transferBloctoToken.cdc \ 13 | --network testnet \ 14 | --arg UFix64:100.0 \ 15 | --arg Address:0x03d1e02a48354e2b \ 16 | --signer blt-admin-testnet \ 17 | --gas-limit 1000 18 | ``` 19 | 20 | ### Transfer BloctoToken in a Batch 21 | ``` 22 | flow transactions send ./transactions/token/transferBloctoTokenBatch.cdc \ 23 | --network mainnet \ 24 | --args-json "$(cat "./arguments/batch/transferBloctoToken.json")" \ 25 | --signer blt-admin-mainnet \ 26 | --gas-limit 9999 27 | ``` 28 | 29 | ### Setup BloctoPass Collection 30 | ``` 31 | flow transactions send ./transactions/token/setupBloctoPassCollection.cdc \ 32 | --network testnet \ 33 | --signer blt-user-testnet \ 34 | --gas-limit 1000 35 | ``` 36 | 37 | ### Withdraw All Unlocked Tokens from BloctoPass 38 | ``` 39 | flow transactions send ./transactions/token/withdrawAllFromBloctoPass.cdc \ 40 | --network testnet \ 41 | --signer blt-user-testnet \ 42 | --gas-limit 1000 43 | ``` 44 | 45 | ### Setup tUSDT Vault 46 | ``` 47 | flow transactions send ./transactions/token/setupTeleportedTetherTokenVault.cdc \ 48 | --network testnet \ 49 | --signer blt-user-testnet \ 50 | --gas-limit 1000 51 | ``` 52 | -------------------------------------------------------------------------------- /transactions/token/TeleportedTetherToken/depositAllowance.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | transaction(teleportAdmin: Address, allowedAmount: UFix64) { 5 | 6 | prepare(admin: auth(BorrowValue) &Account) { 7 | 8 | let adminRef = admin.storage.borrow(from: /storage/teleportedTetherTokenAdmin) 9 | ?? panic("Could not borrow a reference to the admin resource") 10 | 11 | let allowance <- adminRef.createAllowance(allowedAmount: allowedAmount) 12 | 13 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportedTetherToken.TeleportUser}>(/public/teleportedTetherTokenTeleportUser) 14 | ?? panic("Could not borrow a reference of TeleportUser") 15 | 16 | teleportUserRef.depositAllowance(from: <- allowance) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/token/TeleportedTetherToken/setupFreeze.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | transaction(isFreeze: Bool) { 5 | 6 | prepare(admin: auth(BorrowValue) &Account) { 7 | 8 | let adminRef = admin.storage.borrow(from: /storage/teleportedTetherTokenAdmin) 9 | ?? panic("Could not borrow a reference to the admin resource") 10 | if (isFreeze) { 11 | adminRef.freeze() 12 | } else { 13 | adminRef.unfreeze() 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /transactions/token/TeleportedTetherToken/setupTeleportAdmin.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | transaction(allowedAmount: UFix64) { 5 | 6 | prepare(admin: auth(BorrowValue) &Account, teleportAdmin: auth(SaveValue, LoadValue, Capabilities) &Account) { 7 | 8 | let adminRef = admin.storage.borrow(from: /storage/teleportedTetherTokenAdmin) 9 | ?? panic("Could not borrow a reference to the admin resource") 10 | 11 | let teleportAdminRes <- adminRef.createNewTeleportAdmin(allowedAmount: allowedAmount) 12 | 13 | destroy teleportAdmin.storage.load<@TeleportedTetherToken.TeleportAdmin>(from: /storage/teleportedTetherTokenTeleportAdmin) 14 | let cap = teleportAdmin.capabilities.unpublish(/public/teleportedTetherTokenTeleportUser) 15 | teleportAdmin.storage.save(<- teleportAdminRes, to: /storage/teleportedTetherTokenTeleportAdmin) 16 | 17 | let teleportUserCap = teleportAdmin.capabilities.storage.issue<&{TeleportedTetherToken.TeleportUser}>(/storage/teleportedTetherTokenTeleportAdmin) 18 | teleportAdmin.capabilities.publish(teleportUserCap, at: /public/teleportedTetherTokenTeleportUser) 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /transactions/token/TeleportedTetherToken/setupTokenVault.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | transaction { 5 | 6 | prepare(signer: auth(BorrowValue, SaveValue, Capabilities) &Account) { 7 | 8 | // If the account is already set up that's not a problem, but we don't want to replace it 9 | if(signer.storage.borrow<&TeleportedTetherToken.Vault>(from: TeleportedTetherToken.TokenStoragePath) != nil) { 10 | return 11 | } 12 | 13 | // Create a new tUSDT Token Vault and put it in storage 14 | signer.storage.save( 15 | <- TeleportedTetherToken.createEmptyVault(vaultType: Type<@TeleportedTetherToken.Vault>()), 16 | to: TeleportedTetherToken.TokenStoragePath 17 | ) 18 | 19 | // Create a public capability to the Vault that only exposes 20 | // the deposit function through the Receiver interface 21 | let receiverCapability = signer.capabilities.storage.issue<&{FungibleToken.Receiver}>(TeleportedTetherToken.TokenStoragePath) 22 | signer.capabilities.publish(receiverCapability, at: TeleportedTetherToken.TokenPublicReceiverPath) 23 | 24 | // Create a public capability to the Vault that only exposes 25 | // the balance field through the Balance interface 26 | let balanceCapability = signer.capabilities.storage.issue<&{FungibleToken.Balance}>(TeleportedTetherToken.TokenStoragePath) 27 | signer.capabilities.publish(balanceCapability, at: TeleportedTetherToken.TokenPublicBalancePath) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /transactions/token/TeleportedTetherToken/teleportIn.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | transaction(amount: UFix64, target: Address, from: String, hash: String) { 5 | 6 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 7 | 8 | let teleportControlRef = teleportAdmin.storage.borrow(from: /storage/teleportedTetherTokenTeleportAdmin) 9 | ?? panic("Could not borrow a reference to the teleport control resource") 10 | 11 | let vault <- teleportControlRef.teleportIn(amount: amount, from: from.decodeHex(), hash: hash) 12 | 13 | let receiverRef = getAccount(target).capabilities.borrow<&{FungibleToken.Receiver}>(TeleportedTetherToken.TokenPublicReceiverPath) 14 | ?? panic("Could not borrow a reference to Receiver") 15 | 16 | receiverRef.deposit(from: <- vault) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/token/TeleportedTetherToken/teleportOut.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | transaction(teleportAdmin: Address, amount: UFix64, target: String) { 5 | 6 | prepare(signer: auth(BorrowValue) &Account) { 7 | 8 | let teleportUserRef = getAccount(teleportAdmin).capabilities.borrow<&{TeleportedTetherToken.TeleportUser}>(/public/teleportedTetherTokenTeleportUser) 9 | ?? panic("Could not borrow a reference to TeleportUser") 10 | 11 | let vaultRef = signer.storage.borrow(from: TeleportedTetherToken.TokenStoragePath) 12 | ?? panic("Could not borrow a reference to the vault resource") 13 | 14 | let vault <- vaultRef.withdraw(amount: amount) 15 | 16 | teleportUserRef.teleportOut(from: <- vault, to: target.decodeHex()) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/token/TeleportedTetherToken/transfer.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | transaction(amount: UFix64, to: Address) { 5 | 6 | // The Vault resource that holds the tokens that are being transferred 7 | let sentVault: @{FungibleToken.Vault} 8 | 9 | prepare(signer: auth(BorrowValue) &Account) { 10 | 11 | // Get a reference to the signer's stored vault 12 | let vaultRef = signer.storage.borrow(from: TeleportedTetherToken.TokenStoragePath) 13 | ?? panic("Could not borrow reference to the owner's Vault!") 14 | 15 | // Withdraw tokens from the signer's stored vault 16 | self.sentVault <- vaultRef.withdraw(amount: amount) 17 | } 18 | 19 | execute { 20 | 21 | // Get the recipient's public account object 22 | let recipient = getAccount(to) 23 | 24 | // Get a reference to the recipient's Receiver 25 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(TeleportedTetherToken.TokenPublicReceiverPath) 26 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 27 | 28 | // Deposit the withdrawn tokens in the recipient's receiver 29 | receiverRef.deposit(from: <- self.sentVault) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /transactions/token/TeleportedTetherToken/updateFees.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | transaction(inwardFee: UFix64, outwardFee: UFix64) { 5 | 6 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 7 | 8 | let teleportControlRef = teleportAdmin.storage.borrow(from: /storage/teleportedTetherTokenTeleportAdmin) 9 | ?? panic("Could not borrow a reference to the teleport control resource") 10 | 11 | teleportControlRef.updateInwardFee(fee: inwardFee) 12 | teleportControlRef.updateOutwardFee(fee: outwardFee) 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /transactions/token/TeleportedTetherToken/withdrawFee.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "TeleportedTetherToken" 3 | 4 | transaction(to: Address) { 5 | 6 | prepare(teleportAdmin: auth(BorrowValue) &Account) { 7 | 8 | let teleportAdminRef = teleportAdmin.storage.borrow(from: /storage/teleportedTetherTokenTeleportAdmin) 9 | ?? panic("Could not borrow a reference of TeleportAdmin") 10 | 11 | let feeAmount = teleportAdminRef.getFeeAmount() 12 | let vault <- teleportAdminRef.withdrawFee(amount: feeAmount) 13 | 14 | let receiverRef = getAccount(to).capabilities.borrow<&{FungibleToken.Receiver}>(TeleportedTetherToken.TokenPublicReceiverPath) 15 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 16 | receiverRef.deposit(from: <- vault) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /transactions/token/admin/README.md: -------------------------------------------------------------------------------- 1 | # Token 2 | ### Setup Community Sale Lockup Schedule 3 | ``` 4 | flow transactions send ./transactions/token/admin/setupCommunitySaleSchedule.cdc \ 5 | --network testnet \ 6 | --signer blt-admin-testnet \ 7 | --gas-limit 1000 8 | ``` 9 | 10 | ### Mint BloctoPass NFT 11 | ``` 12 | flow transactions send ./transactions/token/admin/mintBloctoPass.cdc \ 13 | --network testnet \ 14 | --arg Address:0x95d4f57daf2fb5ce \ 15 | --signer blt-admin-testnet \ 16 | --gas-limit 1000 17 | ``` 18 | 19 | ### Mint BloctoPass NFT with Custom Lockup Schedule 20 | ``` 21 | flow transactions send ./transactions/token/admin/mintBloctoPassWithCustomLockup.cdc \ 22 | --network testnet \ 23 | --arg Address:0x95d4f57daf2fb5ce \ 24 | --arg UFix64:500.0 \ 25 | --arg UFix64:1625654520.0 \ 26 | --signer blt-admin-testnet \ 27 | --gas-limit 1000 28 | ``` 29 | 30 | ### Mint BloctoPass NFT with Predefined Lockup Schedule 31 | ``` 32 | flow transactions send ./transactions/token/admin/mintBloctoPassWithPredefinedLockup.cdc \ 33 | --network testnet \ 34 | --arg Address:0x95d4f57daf2fb5ce \ 35 | --arg UFix64:500.0 \ 36 | --arg Int:0 \ 37 | --signer blt-admin-testnet \ 38 | --gas-limit 1000 39 | ``` 40 | 41 | ### Setup Blocto Token Minter 42 | ``` 43 | flow transactions send ./transactions/token/admin/setupBloctoTokenMinter.cdc \ 44 | --network testnet \ 45 | --arg UFix64:1000000000.0 \ 46 | --signer blt-admin-testnet \ 47 | --gas-limit 1000 48 | ``` 49 | 50 | ### Destroy Blocto Token Minter from Staking Account 51 | ``` 52 | flow transactions send ./transactions/token/admin/destroyBloctoTokenMinter.cdc \ 53 | --network mainnet \ 54 | --signer blt-staking-admin-mainnet \ 55 | --gas-limit 1000 56 | ``` 57 | 58 | ### Setup Blocto Token Minter for Staking 59 | ``` 60 | flow transactions send ./transactions/token/admin/setupBloctoTokenMinterForStakingSelf.cdc 10000000.0 \ 61 | --network mainnet \ 62 | --signer blt-admin-mainnet \ 63 | --gas-limit 1000 64 | ``` 65 | 66 | ### Setup Blocto Token Minter for Staking (different accounts) 67 | ``` 68 | flow transactions build ./transactions/token/admin/setupBloctoTokenMinterForStaking.cdc 10000000.0 \ 69 | --network mainnet \ 70 | --proposer 0x0f9df91c9121c460 \ 71 | --proposer-key-index 0 \ 72 | --authorizer 0x0f9df91c9121c460 \ 73 | --authorizer 0x6a5a9c49e5b2ad53 \ 74 | --payer 0x6a5a9c49e5b2ad53 \ 75 | --gas-limit 1000 \ 76 | -x payload \ 77 | --save ./build/unsigned.rlp 78 | 79 | flow transactions sign ./build/unsigned.rlp \ 80 | --signer blt-admin-mainnet \ 81 | --filter payload \ 82 | --save ./build/signed-1.rlp 83 | 84 | flow transactions sign ./build/signed-1.rlp \ 85 | --signer blt-staking-admin-mainnet \ 86 | --filter payload \ 87 | --save ./build/signed-2.rlp 88 | 89 | flow transactions send-signed --network mainnet ./build/signed-2.rlp 90 | ``` 91 | 92 | ### Setup BloctoToken Minter for Mining 93 | ``` 94 | flow transactions build ./transactions/token/admin/setupBloctoTokenMinterForStaking.cdc \ 95 | --network testnet \ 96 | --arg UFix64:1000000000.0 \ 97 | --proposer 0xccc5c610f25031c9 \ 98 | --proposer-key-index 0 \ 99 | --authorizer 0xccc5c610f25031c9 \ 100 | --authorizer 0x4e57c4f07871af8d \ 101 | --payer 0x4e57c4f07871af8d \ 102 | --gas-limit 1000 \ 103 | -x payload \ 104 | --save ./build/unsigned.rlp 105 | 106 | flow transactions sign ./build/unsigned.rlp \ 107 | --signer blt-admin-testnet \ 108 | --filter payload \ 109 | --save ./build/signed-1.rlp 110 | 111 | flow transactions sign ./build/signed-1.rlp \ 112 | --signer blt-mining-testnet \ 113 | --filter payload \ 114 | --save ./build/signed-2.rlp 115 | 116 | flow transactions send-signed --network testnet ./build/signed-2.rlp 117 | ``` 118 | 119 | ### Create Public Minter 120 | ``` 121 | flow transactions send ./transactions/token/admin/setupBloctoPassMinterPublic.cdc \ 122 | --network testnet \ 123 | --signer blt-admin-testnet \ 124 | --gas-limit 1000 125 | ``` 126 | -------------------------------------------------------------------------------- /transactions/token/admin/destroyBloctoTokenMinter.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoToken" 2 | 3 | transaction { 4 | prepare(stakingAdmin: auth(Storage) &Account) { 5 | destroy stakingAdmin.storage.load<@BloctoToken.Minter>(from: /storage/bloctoTokenStakingMinter) 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /transactions/token/admin/mintBloctoPass.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | transaction(address: Address) { 5 | 6 | prepare(signer: AuthAccount) { 7 | let minter = signer 8 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 9 | ?? panic("Signer is not the admin") 10 | 11 | let nftCollectionRef = getAccount(address).getCapability(BloctoPass.CollectionPublicPath) 12 | .borrow<&{NonFungibleToken.CollectionPublic}>() 13 | ?? panic("Could not borrow blocto pass collection public reference") 14 | 15 | minter.mintNFT(recipient: nftCollectionRef, metadata: {}) 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /transactions/token/admin/mintBloctoPassForFounders.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 3 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 4 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 5 | 6 | transaction(address: Address, amount: UFix64) { 7 | 8 | prepare(signer: AuthAccount) { 9 | let minter = signer 10 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 11 | ?? panic("Signer is not the admin") 12 | 13 | let nftCollectionRef = getAccount(address).getCapability(BloctoPass.CollectionPublicPath) 14 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 15 | ?? panic("Could not borrow blocto pass collection public reference") 16 | 17 | // Make sure user does not already have a BloctoPass 18 | assert ( 19 | nftCollectionRef.getIDs().length == 0, 20 | message: "User already has a BloctoPass" 21 | ) 22 | 23 | let bltVaultRef = signer 24 | .borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 25 | ?? panic("Cannot get BLT vault reference") 26 | 27 | let bltVault <- bltVaultRef.withdraw(amount: amount) 28 | 29 | let metadata: {String: String} = { 30 | "origin": "Blocto Founders" 31 | } 32 | 33 | minter.mintNFTWithPredefinedLockup( 34 | recipient: nftCollectionRef, 35 | metadata: metadata, 36 | vault: <- bltVault, 37 | lockupScheduleId: 3 38 | ) 39 | 40 | // Get a reference to the signer's stored vault 41 | let flowVaultRef = signer.borrow<&FungibleToken.Vault>(from: /storage/flowTokenVault) 42 | ?? panic("Could not borrow reference to the owner's Vault!") 43 | 44 | // Get the recipient's public account object 45 | let recipient = getAccount(address) 46 | 47 | // Get a reference to the recipient's FLOW Receiver 48 | let receiverRef = recipient.getCapability(/public/flowTokenReceiver) 49 | .borrow<&{FungibleToken.Receiver}>() 50 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 51 | 52 | // Deposit the withdrawn tokens in the recipient's receiver 53 | receiverRef.deposit(from: <-flowVaultRef.withdraw(amount: 0.0001)) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /transactions/token/admin/mintBloctoPassForPrivateSale.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 3 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 4 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 5 | 6 | transaction(address: Address, amount: UFix64) { 7 | 8 | prepare(signer: AuthAccount) { 9 | let minter = signer 10 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 11 | ?? panic("Signer is not the admin") 12 | 13 | let nftCollectionRef = getAccount(address).getCapability(BloctoPass.CollectionPublicPath) 14 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 15 | ?? panic("Could not borrow blocto pass collection public reference") 16 | 17 | // Make sure user does not already have a BloctoPass 18 | assert ( 19 | nftCollectionRef.getIDs().length == 0, 20 | message: "User already has a BloctoPass" 21 | ) 22 | 23 | let bltVaultRef = signer 24 | .borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 25 | ?? panic("Cannot get BLT vault reference") 26 | 27 | let bltVault <- bltVaultRef.withdraw(amount: amount) 28 | 29 | let metadata: {String: String} = { 30 | "origin": "Private Sale" 31 | } 32 | 33 | minter.mintNFTWithPredefinedLockup( 34 | recipient: nftCollectionRef, 35 | metadata: metadata, 36 | vault: <- bltVault, 37 | lockupScheduleId: 1 38 | ) 39 | 40 | // Get a reference to the signer's stored vault 41 | let flowVaultRef = signer.borrow<&FungibleToken.Vault>(from: /storage/flowTokenVault) 42 | ?? panic("Could not borrow reference to the owner's Vault!") 43 | 44 | // Get the recipient's public account object 45 | let recipient = getAccount(address) 46 | 47 | // Get a reference to the recipient's FLOW Receiver 48 | let receiverRef = recipient.getCapability(/public/flowTokenReceiver) 49 | .borrow<&{FungibleToken.Receiver}>() 50 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 51 | 52 | // Deposit the withdrawn tokens in the recipient's receiver 53 | receiverRef.deposit(from: <-flowVaultRef.withdraw(amount: 0.0001)) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /transactions/token/admin/mintBloctoPassForTeam.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 3 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 4 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 5 | 6 | transaction(address: Address, amount: UFix64) { 7 | 8 | prepare(signer: AuthAccount) { 9 | let minter = signer 10 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 11 | ?? panic("Signer is not the admin") 12 | 13 | let nftCollectionRef = getAccount(address).getCapability(BloctoPass.CollectionPublicPath) 14 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 15 | ?? panic("Could not borrow blocto pass collection public reference") 16 | 17 | // Make sure user does not already have a BloctoPass 18 | assert ( 19 | nftCollectionRef.getIDs().length == 0, 20 | message: "User already has a BloctoPass" 21 | ) 22 | 23 | let bltVaultRef = signer 24 | .borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 25 | ?? panic("Cannot get BLT vault reference") 26 | 27 | let bltVault <- bltVaultRef.withdraw(amount: amount) 28 | 29 | let metadata: {String: String} = { 30 | "origin": "Blocto Team" 31 | } 32 | 33 | minter.mintNFTWithPredefinedLockup( 34 | recipient: nftCollectionRef, 35 | metadata: metadata, 36 | vault: <- bltVault, 37 | lockupScheduleId: 2 38 | ) 39 | 40 | // Get a reference to the signer's stored vault 41 | let flowVaultRef = signer.borrow<&FungibleToken.Vault>(from: /storage/flowTokenVault) 42 | ?? panic("Could not borrow reference to the owner's Vault!") 43 | 44 | // Get the recipient's public account object 45 | let recipient = getAccount(address) 46 | 47 | // Get a reference to the recipient's FLOW Receiver 48 | let receiverRef = recipient.getCapability(/public/flowTokenReceiver) 49 | .borrow<&{FungibleToken.Receiver}>() 50 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 51 | 52 | // Deposit the withdrawn tokens in the recipient's receiver 53 | receiverRef.deposit(from: <-flowVaultRef.withdraw(amount: 0.0001)) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /transactions/token/admin/mintBloctoPassWithCustomLockup.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 3 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 4 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 5 | 6 | transaction(address: Address, amount: UFix64, startDate: UFix64) { 7 | 8 | prepare(signer: AuthAccount) { 9 | let minter = signer 10 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 11 | ?? panic("Signer is not the admin") 12 | 13 | let nftCollectionRef = getAccount(address).getCapability(BloctoPass.CollectionPublicPath) 14 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 15 | ?? panic("Could not borrow blocto pass collection public reference") 16 | 17 | // Make sure user does not already have a BloctoPass 18 | assert ( 19 | nftCollectionRef.getIDs().length == 0, 20 | message: "User already has a BloctoPass" 21 | ) 22 | 23 | let bltVaultRef = signer 24 | .borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 25 | ?? panic("Cannot get BLT vault reference") 26 | 27 | let bltVault <- bltVaultRef.withdraw(amount: amount) 28 | 29 | let metadata: {String: String} = { 30 | "origin": "Private Sale" 31 | } 32 | 33 | let months = 30.0 * 24.0 * 60.0 * 60.0 // seconds 34 | let lockupSchedule = { 35 | 0.0 : 1.0, 36 | startDate : 1.0, 37 | startDate + 6.0 * months : 17.0 / 18.0, 38 | startDate + 7.0 * months : 16.0 / 18.0, 39 | startDate + 8.0 * months : 15.0 / 18.0, 40 | startDate + 9.0 * months : 14.0 / 18.0, 41 | startDate + 10.0 * months : 13.0 / 18.0, 42 | startDate + 11.0 * months : 12.0 / 18.0, 43 | startDate + 12.0 * months : 11.0 / 18.0, 44 | startDate + 13.0 * months : 10.0 / 18.0, 45 | startDate + 14.0 * months : 9.0 / 18.0, 46 | startDate + 15.0 * months : 8.0 / 18.0, 47 | startDate + 16.0 * months : 7.0 / 18.0, 48 | startDate + 17.0 * months : 6.0 / 18.0, 49 | startDate + 18.0 * months : 5.0 / 18.0, 50 | startDate + 19.0 * months : 4.0 / 18.0, 51 | startDate + 20.0 * months : 3.0 / 18.0, 52 | startDate + 21.0 * months : 2.0 / 18.0, 53 | startDate + 22.0 * months : 1.0 / 18.0, 54 | startDate + 23.0 * months : 0.0 55 | } 56 | 57 | minter.mintNFTWithCustomLockup( 58 | recipient: nftCollectionRef, 59 | metadata: metadata, 60 | vault: <- bltVault, 61 | lockupSchedule: lockupSchedule 62 | ) 63 | 64 | // Get a reference to the signer's stored vault 65 | let flowVaultRef = signer.borrow<&FungibleToken.Vault>(from: /storage/flowTokenVault) 66 | ?? panic("Could not borrow reference to the owner's Vault!") 67 | 68 | // Get the recipient's public account object 69 | let recipient = getAccount(address) 70 | 71 | // Get a reference to the recipient's FLOW Receiver 72 | let receiverRef = recipient.getCapability(/public/flowTokenReceiver) 73 | .borrow<&{FungibleToken.Receiver}>() 74 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 75 | 76 | // Deposit the withdrawn tokens in the recipient's receiver 77 | receiverRef.deposit(from: <-flowVaultRef.withdraw(amount: 0.0001)) 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /transactions/token/admin/mintBloctoPassWithCustomLockupNew.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../../contracts/flow/token/FungibleToken.cdc" 2 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 3 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 4 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 5 | 6 | transaction(address: Address, amount: UFix64, startDate: UFix64) { 7 | 8 | prepare(signer: AuthAccount) { 9 | let minter = signer 10 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 11 | ?? panic("Signer is not the admin") 12 | 13 | let nftCollectionRef = getAccount(address).getCapability(BloctoPass.CollectionPublicPath) 14 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 15 | ?? panic("Could not borrow blocto pass collection public reference") 16 | 17 | // Make sure user does not already have a BloctoPass 18 | assert ( 19 | nftCollectionRef.getIDs().length == 0, 20 | message: "User already has a BloctoPass" 21 | ) 22 | 23 | let bltVaultRef = signer 24 | .borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 25 | ?? panic("Cannot get BLT vault reference") 26 | 27 | let bltVault <- bltVaultRef.withdraw(amount: amount) 28 | 29 | let metadata: {String: String} = { 30 | "origin": "Private Sale" 31 | } 32 | 33 | let months = 30.0 * 24.0 * 60.0 * 60.0 // seconds 34 | let lockupSchedule = { 35 | 0.0 : 1.0, 36 | startDate : 1.0, 37 | startDate + 12.0 * months : 12.0 / 24.0, 38 | startDate + 13.0 * months : 11.0 / 24.0, 39 | startDate + 14.0 * months : 10.0 / 24.0, 40 | startDate + 15.0 * months : 9.0 / 24.0, 41 | startDate + 16.0 * months : 8.0 / 24.0, 42 | startDate + 17.0 * months : 7.0 / 24.0, 43 | startDate + 18.0 * months : 6.0 / 24.0, 44 | startDate + 19.0 * months : 5.0 / 24.0, 45 | startDate + 20.0 * months : 4.0 / 24.0, 46 | startDate + 21.0 * months : 3.0 / 24.0, 47 | startDate + 22.0 * months : 2.0 / 24.0, 48 | startDate + 23.0 * months : 1.0 / 24.0, 49 | startDate + 24.0 * months : 0.0 50 | } 51 | 52 | minter.mintNFTWithCustomLockup( 53 | recipient: nftCollectionRef, 54 | metadata: metadata, 55 | vault: <- bltVault, 56 | lockupSchedule: lockupSchedule 57 | ) 58 | 59 | // Get a reference to the signer's stored vault 60 | let flowVaultRef = signer.borrow<&FungibleToken.Vault>(from: /storage/flowTokenVault) 61 | ?? panic("Could not borrow reference to the owner's Vault!") 62 | 63 | // Get the recipient's public account object 64 | let recipient = getAccount(address) 65 | 66 | // Get a reference to the recipient's FLOW Receiver 67 | let receiverRef = recipient.getCapability(/public/flowTokenReceiver) 68 | .borrow<&{FungibleToken.Receiver}>() 69 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 70 | 71 | // Deposit the withdrawn tokens in the recipient's receiver 72 | receiverRef.deposit(from: <-flowVaultRef.withdraw(amount: 0.0001)) 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /transactions/token/admin/mintBloctoPassWithPredefinedLockup.cdc: -------------------------------------------------------------------------------- 1 | import BloctoToken from "../../../contracts/flow/token/BloctoToken.cdc" 2 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 3 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 4 | 5 | transaction(address: Address, amount: UFix64, lockupScheduleId: Int) { 6 | 7 | prepare(signer: AuthAccount) { 8 | let minter = signer 9 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 10 | ?? panic("Signer is not the admin") 11 | 12 | let nftCollectionRef = getAccount(address).getCapability(BloctoPass.CollectionPublicPath) 13 | .borrow<&{NonFungibleToken.CollectionPublic, BloctoPass.CollectionPublic}>() 14 | ?? panic("Could not borrow blocto pass collection public reference") 15 | 16 | let bltVaultRef = signer 17 | .borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 18 | ?? panic("Cannot get BLT vault reference") 19 | 20 | let bltVault <- bltVaultRef.withdraw(amount: amount) 21 | 22 | let metadata: {String: String} = { 23 | "origin": "Private Sale" 24 | } 25 | 26 | minter.mintNFTWithPredefinedLockup( 27 | recipient: nftCollectionRef, 28 | metadata: metadata, 29 | vault: <- bltVault, 30 | lockupScheduleId: lockupScheduleId 31 | ) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /transactions/token/admin/setupBloctoPassMinterPublic.cdc: -------------------------------------------------------------------------------- 1 | import "BloctoPass" 2 | 3 | transaction { 4 | prepare(signer: auth(BorrowValue, SaveValue, Capabilities) &Account) { 5 | // create a public capability to mint Blocto Pass 6 | let balanceCapability = signer.capabilities.storage.issue<&{BloctoPass.MinterPublic}>(BloctoPass.MinterStoragePath) 7 | signer.capabilities.publish(balanceCapability, at: BloctoPass.MinterPublicPath) 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /transactions/token/admin/setupBloctoTokenMinter.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | 4 | transaction(allowedAmount: UFix64) { 5 | 6 | prepare(signer: auth(Storage) &Account) { 7 | let admin = signer.storage 8 | .borrow(from: /storage/bloctoTokenAdmin) 9 | ?? panic("Signer is not the admin") 10 | 11 | let minter <- admin.createNewMinter(allowedAmount: allowedAmount) 12 | 13 | signer.storage.save(<-minter, to: BloctoToken.TokenMinterStoragePath) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /transactions/token/admin/setupBloctoTokenMinterForMining.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | 4 | transaction(allowedAmount: UFix64) { 5 | 6 | prepare(signer: auth(BorrowValue) &Account, minter: auth(Storage) &Account) { 7 | let admin = signer.storage 8 | .borrow(from: /storage/bloctoTokenAdmin) 9 | ?? panic("Signer is not the admin") 10 | 11 | let minterResource <- admin.createNewMinter(allowedAmount: allowedAmount) 12 | 13 | minter.storage.save(<-minterResource, to: BloctoToken.TokenMinterStoragePath) 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /transactions/token/admin/setupBloctoTokenMinterForStaking.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | 4 | transaction(allowedAmount: UFix64) { 5 | 6 | prepare(bltAdmin: auth(BorrowValue) &Account, stakingAdmin: auth(Storage) &Account) { 7 | let admin = bltAdmin.storage 8 | .borrow(from: /storage/bloctoTokenAdmin) 9 | ?? panic("Signer is not the admin") 10 | 11 | let minter <- admin.createNewMinter(allowedAmount: allowedAmount) 12 | 13 | destroy stakingAdmin.storage.load<@BloctoToken.Minter>(from: /storage/bloctoTokenStakingMinter) 14 | stakingAdmin.storage.save(<-minter, to: /storage/bloctoTokenStakingMinter) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /transactions/token/admin/setupBloctoTokenMinterForStakingSelf.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | 4 | transaction(allowedAmount: UFix64) { 5 | 6 | prepare(bltAdmin: auth(BorrowValue, Storage) &Account) { 7 | let admin = bltAdmin.storage 8 | .borrow(from: /storage/bloctoTokenAdmin) 9 | ?? panic("Signer is not the admin") 10 | 11 | let minter <- admin.createNewMinter(allowedAmount: allowedAmount) 12 | 13 | destroy bltAdmin.storage.load<@BloctoToken.Minter>(from: /storage/bloctoTokenStakingMinter) 14 | bltAdmin.storage.save(<-minter, to: /storage/bloctoTokenStakingMinter) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /transactions/token/admin/setupCommunitySaleSchedule.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | transaction() { 5 | 6 | prepare(signer: AuthAccount) { 7 | let minter = signer 8 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 9 | ?? panic("Signer is not the admin") 10 | 11 | // July 22, 2021 00:00:00 AM GMT 12 | let saleDate = 1626912000.0 13 | let months = 30.0 * 24.0 * 60.0 * 60.0 // seconds 14 | 15 | // Lockup schedule for BLT community sale 16 | let lockupSchedule = { 17 | 0.0 : 1.0, 18 | saleDate : 1.0, 19 | saleDate + 6.0 * months : 17.0 / 18.0, 20 | saleDate + 7.0 * months : 16.0 / 18.0, 21 | saleDate + 8.0 * months : 15.0 / 18.0, 22 | saleDate + 9.0 * months : 14.0 / 18.0, 23 | saleDate + 10.0 * months : 13.0 / 18.0, 24 | saleDate + 11.0 * months : 12.0 / 18.0, 25 | saleDate + 12.0 * months : 11.0 / 18.0, 26 | saleDate + 13.0 * months : 10.0 / 18.0, 27 | saleDate + 14.0 * months : 9.0 / 18.0, 28 | saleDate + 15.0 * months : 8.0 / 18.0, 29 | saleDate + 16.0 * months : 7.0 / 18.0, 30 | saleDate + 17.0 * months : 6.0 / 18.0, 31 | saleDate + 18.0 * months : 5.0 / 18.0, 32 | saleDate + 19.0 * months : 4.0 / 18.0, 33 | saleDate + 20.0 * months : 3.0 / 18.0, 34 | saleDate + 21.0 * months : 2.0 / 18.0, 35 | saleDate + 22.0 * months : 1.0 / 18.0, 36 | saleDate + 23.0 * months : 0.0 37 | } 38 | 39 | minter.setupPredefinedLockupSchedule(lockupSchedule: lockupSchedule) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /transactions/token/admin/setupFounderSchedule.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | transaction() { 5 | 6 | prepare(signer: AuthAccount) { 7 | let minter = signer 8 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 9 | ?? panic("Signer is not the admin") 10 | 11 | // July 22, 2021 00:00:00 AM GMT 12 | let saleDate = 1626912000.0 13 | let months = 30.0 * 24.0 * 60.0 * 60.0 // seconds 14 | 15 | // Lockup schedule for Blocto founders 16 | let lockupSchedule = { 17 | 0.0 : 1.0, 18 | saleDate : 1.0, 19 | saleDate + 6.0 * months : 41.0 / 42.0, 20 | saleDate + 7.0 * months : 40.0 / 42.0, 21 | saleDate + 8.0 * months : 39.0 / 42.0, 22 | saleDate + 9.0 * months : 38.0 / 42.0, 23 | saleDate + 10.0 * months : 37.0 / 42.0, 24 | saleDate + 11.0 * months : 36.0 / 42.0, 25 | saleDate + 12.0 * months : 35.0 / 42.0, 26 | saleDate + 13.0 * months : 34.0 / 42.0, 27 | saleDate + 14.0 * months : 33.0 / 42.0, 28 | saleDate + 15.0 * months : 32.0 / 42.0, 29 | saleDate + 16.0 * months : 31.0 / 42.0, 30 | saleDate + 17.0 * months : 30.0 / 42.0, 31 | saleDate + 18.0 * months : 29.0 / 42.0, 32 | saleDate + 19.0 * months : 28.0 / 42.0, 33 | saleDate + 20.0 * months : 27.0 / 42.0, 34 | saleDate + 21.0 * months : 26.0 / 42.0, 35 | saleDate + 22.0 * months : 25.0 / 42.0, 36 | saleDate + 23.0 * months : 24.0 / 42.0, 37 | saleDate + 24.0 * months : 23.0 / 42.0, 38 | saleDate + 25.0 * months : 22.0 / 42.0, 39 | saleDate + 26.0 * months : 21.0 / 42.0, 40 | saleDate + 27.0 * months : 20.0 / 42.0, 41 | saleDate + 28.0 * months : 19.0 / 42.0, 42 | saleDate + 29.0 * months : 18.0 / 42.0, 43 | saleDate + 30.0 * months : 17.0 / 42.0, 44 | saleDate + 31.0 * months : 16.0 / 42.0, 45 | saleDate + 32.0 * months : 15.0 / 42.0, 46 | saleDate + 33.0 * months : 14.0 / 42.0, 47 | saleDate + 34.0 * months : 13.0 / 42.0, 48 | saleDate + 35.0 * months : 12.0 / 42.0, 49 | saleDate + 36.0 * months : 11.0 / 42.0, 50 | saleDate + 37.0 * months : 10.0 / 42.0, 51 | saleDate + 38.0 * months : 9.0 / 42.0, 52 | saleDate + 39.0 * months : 8.0 / 42.0, 53 | saleDate + 40.0 * months : 7.0 / 42.0, 54 | saleDate + 41.0 * months : 6.0 / 42.0, 55 | saleDate + 42.0 * months : 5.0 / 42.0, 56 | saleDate + 43.0 * months : 4.0 / 42.0, 57 | saleDate + 44.0 * months : 3.0 / 42.0, 58 | saleDate + 45.0 * months : 2.0 / 42.0, 59 | saleDate + 46.0 * months : 1.0 / 42.0, 60 | saleDate + 47.0 * months : 0.0 61 | } 62 | 63 | minter.setupPredefinedLockupSchedule(lockupSchedule: lockupSchedule) 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /transactions/token/admin/setupPrivateSaleSchedule.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | transaction() { 5 | 6 | prepare(signer: AuthAccount) { 7 | let minter = signer 8 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 9 | ?? panic("Signer is not the admin") 10 | 11 | // July 22, 2021 00:00:00 AM GMT 12 | let saleDate = 1626912000.0 13 | let months = 30.0 * 24.0 * 60.0 * 60.0 // seconds 14 | 15 | // Lockup schedule for BLT private sale 16 | let lockupSchedule = { 17 | 0.0 : 1.0, 18 | saleDate : 1.0, 19 | saleDate + 6.0 * months : 17.0 / 18.0, 20 | saleDate + 7.0 * months : 16.0 / 18.0, 21 | saleDate + 8.0 * months : 15.0 / 18.0, 22 | saleDate + 9.0 * months : 14.0 / 18.0, 23 | saleDate + 10.0 * months : 13.0 / 18.0, 24 | saleDate + 11.0 * months : 12.0 / 18.0, 25 | saleDate + 12.0 * months : 11.0 / 18.0, 26 | saleDate + 13.0 * months : 10.0 / 18.0, 27 | saleDate + 14.0 * months : 9.0 / 18.0, 28 | saleDate + 15.0 * months : 8.0 / 18.0, 29 | saleDate + 16.0 * months : 7.0 / 18.0, 30 | saleDate + 17.0 * months : 6.0 / 18.0, 31 | saleDate + 18.0 * months : 5.0 / 18.0, 32 | saleDate + 19.0 * months : 4.0 / 18.0, 33 | saleDate + 20.0 * months : 3.0 / 18.0, 34 | saleDate + 21.0 * months : 2.0 / 18.0, 35 | saleDate + 22.0 * months : 1.0 / 18.0, 36 | saleDate + 23.0 * months : 0.0 37 | } 38 | 39 | minter.setupPredefinedLockupSchedule(lockupSchedule: lockupSchedule) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /transactions/token/admin/setupTeamSchedule.cdc: -------------------------------------------------------------------------------- 1 | import NonFungibleToken from "../../../contracts/flow/token/NonFungibleToken.cdc" 2 | import BloctoPass from "../../../contracts/flow/token/BloctoPass.cdc" 3 | 4 | transaction() { 5 | 6 | prepare(signer: AuthAccount) { 7 | let minter = signer 8 | .borrow<&BloctoPass.NFTMinter>(from: BloctoPass.MinterStoragePath) 9 | ?? panic("Signer is not the admin") 10 | 11 | // July 22, 2021 00:00:00 AM GMT 12 | let saleDate = 1626912000.0 13 | let months = 30.0 * 24.0 * 60.0 * 60.0 // seconds 14 | 15 | // Lockup schedule for Blocto team 16 | let lockupSchedule = { 17 | 0.0 : 1.0, 18 | saleDate : 1.0, 19 | saleDate + 6.0 * months : 17.0 / 18.0, 20 | saleDate + 7.0 * months : 16.0 / 18.0, 21 | saleDate + 8.0 * months : 15.0 / 18.0, 22 | saleDate + 9.0 * months : 14.0 / 18.0, 23 | saleDate + 10.0 * months : 13.0 / 18.0, 24 | saleDate + 11.0 * months : 12.0 / 18.0, 25 | saleDate + 12.0 * months : 11.0 / 18.0, 26 | saleDate + 13.0 * months : 10.0 / 18.0, 27 | saleDate + 14.0 * months : 9.0 / 18.0, 28 | saleDate + 15.0 * months : 8.0 / 18.0, 29 | saleDate + 16.0 * months : 7.0 / 18.0, 30 | saleDate + 17.0 * months : 6.0 / 18.0, 31 | saleDate + 18.0 * months : 5.0 / 18.0, 32 | saleDate + 19.0 * months : 4.0 / 18.0, 33 | saleDate + 20.0 * months : 3.0 / 18.0, 34 | saleDate + 21.0 * months : 2.0 / 18.0, 35 | saleDate + 22.0 * months : 1.0 / 18.0, 36 | saleDate + 23.0 * months : 0.0 37 | } 38 | 39 | minter.setupPredefinedLockupSchedule(lockupSchedule: lockupSchedule) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /transactions/token/setupBloctoPassCollection.cdc: -------------------------------------------------------------------------------- 1 | import "NonFungibleToken" 2 | import "BloctoPass" 3 | 4 | transaction { 5 | 6 | prepare(signer: auth(BorrowValue, SaveValue, Capabilities) &Account) { 7 | if signer.storage.borrow<&BloctoPass.Collection>(from: BloctoPass.CollectionStoragePath) == nil { 8 | 9 | let collection <- BloctoPass.createEmptyCollection(nftType: Type<@BloctoPass.NFT>()) as! @BloctoPass.Collection 10 | 11 | signer.storage.save(<-collection, to: BloctoPass.CollectionStoragePath) 12 | 13 | // create a public capability for the collection 14 | signer.capabilities.unpublish(BloctoPass.CollectionPublicPath) 15 | let collectionCap = signer.capabilities.storage.issue<&BloctoPass.Collection>(BloctoPass.CollectionStoragePath) 16 | signer.capabilities.publish(collectionCap, at: BloctoPass.CollectionPublicPath) 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /transactions/token/setupBloctoTokenVault.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | 4 | transaction { 5 | 6 | prepare(signer: auth(BorrowValue, SaveValue, Capabilities) &Account) { 7 | 8 | // If the account is already set up that's not a problem, but we don't want to replace it 9 | if(signer.storage.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) != nil) { 10 | return 11 | } 12 | 13 | // Create a new Blocto Token Vault and put it in storage 14 | signer.storage.save( 15 | <- BloctoToken.createEmptyVault(vaultType: Type<@BloctoToken.Vault>()), 16 | to: BloctoToken.TokenStoragePath 17 | ) 18 | 19 | // Create a public capability to the Vault that only exposes 20 | // the deposit function through the Receiver interface 21 | let receiverCapability = signer.capabilities.storage.issue<&{FungibleToken.Receiver}>(BloctoToken.TokenStoragePath) 22 | signer.capabilities.publish(receiverCapability, at: BloctoToken.TokenPublicReceiverPath) 23 | 24 | // Create a public capability to the Vault that only exposes 25 | // the balance field through the Balance interface 26 | let balanceCapability = signer.capabilities.storage.issue<&{FungibleToken.Balance}>(BloctoToken.TokenStoragePath) 27 | signer.capabilities.publish(balanceCapability, at: BloctoToken.TokenPublicBalancePath) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /transactions/token/setupFUSDVault.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../contracts/flow/token/FungibleToken.cdc" 2 | import FUSD from "../../contracts/flow/token/FUSD.cdc" 3 | 4 | transaction { 5 | 6 | prepare(signer: AuthAccount) { 7 | 8 | let VaultStoragePath = /storage/fusdVault 9 | let ReceiverPublicPath = /public/fusdReceiver 10 | let BalancePublicPath = /public/fusdBalance 11 | if signer.borrow<&FUSD.Vault>(from: VaultStoragePath) == nil { 12 | // Create a new FUSD Vault and put it in storage 13 | signer.save(<-FUSD.createEmptyVault(), to: VaultStoragePath) 14 | 15 | // Create a public capability to the Vault that only exposes 16 | // the deposit function through the Receiver interface 17 | signer.link<&FUSD.Vault{FungibleToken.Receiver}>( 18 | ReceiverPublicPath, 19 | target: VaultStoragePath 20 | ) 21 | 22 | // Create a public capability to the Vault that only exposes 23 | // the balance field through the Balance interface 24 | signer.link<&FUSD.Vault{FungibleToken.Balance}>( 25 | BalancePublicPath, 26 | target: VaultStoragePath 27 | ) 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /transactions/token/transferBloctoToken.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | 4 | transaction(amount: UFix64, to: Address) { 5 | 6 | // The Vault resource that holds the tokens that are being transferred 7 | let sentVault: @{FungibleToken.Vault} 8 | 9 | prepare(signer: auth(BorrowValue) &Account) { 10 | 11 | // Get a reference to the signer's stored vault 12 | let vaultRef = signer.storage.borrow(from: BloctoToken.TokenStoragePath) 13 | ?? panic("Could not borrow reference to the owner's Vault!") 14 | 15 | // Withdraw tokens from the signer's stored vault 16 | self.sentVault <- vaultRef.withdraw(amount: amount) 17 | } 18 | 19 | execute { 20 | 21 | // Get the recipient's public account object 22 | let recipient = getAccount(to) 23 | 24 | // Get a reference to the recipient's Receiver 25 | let receiverRef = recipient.capabilities.borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 26 | ?? panic("Could not borrow receiver reference to the recipient's Vault") 27 | 28 | // Deposit the withdrawn tokens in the recipient's receiver 29 | receiverRef.deposit(from: <-self.sentVault) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /transactions/token/transferBloctoTokenBatch.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | 4 | transaction(addresses: [Address], amounts: [UFix64]) { 5 | 6 | // The Vault resource that holds the tokens that are being transferred 7 | let vaultRef: auth(FungibleToken.Withdraw) &BloctoToken.Vault 8 | 9 | prepare(signer: auth(BorrowValue) &Account) { 10 | assert( 11 | addresses.length == amounts.length, 12 | message: "Input length mismatch" 13 | ) 14 | 15 | // Get a reference to the signer's stored vault 16 | self.vaultRef = signer.storage.borrow(from: BloctoToken.TokenStoragePath) 17 | ?? panic("Could not borrow reference to the owner's Vault!") 18 | } 19 | 20 | execute { 21 | // Send BLT to all addresses in the list 22 | var index = 0 23 | while index < addresses.length { 24 | 25 | // Get the recipient's public account object 26 | let recipient = getAccount(addresses[index]) 27 | 28 | // Get a reference to the recipient's Receiver 29 | let receiverRef = recipient.capabilities 30 | .borrow<&{FungibleToken.Receiver}>(BloctoToken.TokenPublicReceiverPath) 31 | ?? panic("Could not borrow receiver reference to the recipient's Vault".concat(addresses[index].toString())) 32 | 33 | // Deposit the withdrawn tokens in the recipient's receiver 34 | receiverRef.deposit(from: <-self.vaultRef.withdraw(amount: amounts[index])) 35 | 36 | index = index + 1 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /transactions/token/transferBloctoTokenIntoPass.cdc: -------------------------------------------------------------------------------- 1 | import "FungibleToken" 2 | import "BloctoToken" 3 | import "BloctoPass" 4 | 5 | transaction(amount: UFix64) { 6 | 7 | // The Vault resource that holds the tokens that are being transferred 8 | let sentVault: @{FungibleToken.Vault} 9 | 10 | // The private reference to user's BloctoPass 11 | let bloctoPassRef: &BloctoPass.NFT 12 | 13 | prepare(signer: auth(BorrowValue) &Account) { 14 | 15 | // Get a reference to the signer's stored vault 16 | let vaultRef = signer.storage.borrow(from: BloctoToken.TokenStoragePath) 17 | ?? panic("Could not borrow reference to the owner's Vault!") 18 | 19 | // Withdraw tokens from the signer's stored vault 20 | self.sentVault <- vaultRef.withdraw(amount: amount) 21 | 22 | // Get a reference to the signer's BloctoPass 23 | let bloctoPassCollectionRef = signer.storage.borrow(from: /storage/bloctoPassCollection) 24 | ?? panic("Could not borrow reference to the owner's BloctoPass collection!") 25 | 26 | let ids = bloctoPassCollectionRef.getIDs() 27 | 28 | // Get a reference to the 29 | self.bloctoPassRef = bloctoPassCollectionRef.borrowBloctoPassPrivate(id: ids[0]) 30 | } 31 | 32 | execute { 33 | // Deposit BLT balance into BloctoPass first 34 | self.bloctoPassRef.deposit(from: <- self.sentVault) 35 | } 36 | } -------------------------------------------------------------------------------- /transactions/token/transferFUSDBatch.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../contracts/flow/token/FungibleToken.cdc" 2 | import FUSD from "../../contracts/flow/token/FUSD.cdc" 3 | 4 | transaction(addresses: [Address], amounts: [UFix64]) { 5 | 6 | // The Vault resource that holds the tokens that are being transferred 7 | let vaultRef: &FUSD.Vault 8 | 9 | prepare(signer: AuthAccount) { 10 | assert( 11 | addresses.length == amounts.length, 12 | message: "Input length mismatch" 13 | ) 14 | 15 | // Get a reference to the signer's stored vault 16 | self.vaultRef = signer.borrow<&FUSD.Vault>(from: /storage/fusdVault) 17 | ?? panic("Could not borrow reference to the owner's Vault!") 18 | } 19 | 20 | execute { 21 | // Send FUSD to all addresses in the list 22 | var index = 0 23 | while index < addresses.length { 24 | 25 | if amounts[index] > 0.0 { 26 | 27 | // Get the recipient's public account object 28 | let recipient = getAccount(addresses[index]) 29 | 30 | // Get a reference to the recipient's Receiver 31 | let receiverRef = recipient.getCapability(/public/fusdReceiver) 32 | .borrow<&{FungibleToken.Receiver}>() 33 | ?? panic("Could not borrow receiver reference to the recipient's Vault: ".concat(addresses[index].toString())) 34 | 35 | // Deposit the withdrawn tokens in the recipient's receiver 36 | receiverRef.deposit(from: <-self.vaultRef.withdraw(amount: amounts[index])) 37 | 38 | } 39 | 40 | index = index + 1 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /transactions/token/withdrawAllFromBloctoPass.cdc: -------------------------------------------------------------------------------- 1 | import FungibleToken from "../../contracts/flow/token/FungibleToken.cdc" 2 | import BloctoToken from "../../contracts/flow/token/BloctoToken.cdc" 3 | import BloctoPass from "../../contracts/flow/token/BloctoPass.cdc" 4 | 5 | transaction() { 6 | // The private reference to user's BloctoToken vault 7 | let vaultRef: &BloctoToken.Vault 8 | 9 | // The private reference to user's BloctoPass 10 | let bloctoPassRef: &BloctoPass.NFT 11 | 12 | prepare(signer: AuthAccount) { 13 | 14 | // Get a reference to the signer's stored vault 15 | self.vaultRef = signer.borrow<&BloctoToken.Vault>(from: BloctoToken.TokenStoragePath) 16 | ?? panic("Could not borrow reference to the owner's Vault!") 17 | 18 | // Get a reference to the signer's BloctoPass 19 | let bloctoPassCollectionRef = signer.borrow<&BloctoPass.Collection>(from: /storage/bloctoPassCollection) 20 | ?? panic("Could not borrow reference to the owner's BloctoPass collection!") 21 | 22 | let ids = bloctoPassCollectionRef.getIDs() 23 | 24 | // Get a reference to the 25 | self.bloctoPassRef = bloctoPassCollectionRef.borrowBloctoPassPrivate(id: ids[0]) 26 | } 27 | 28 | execute { 29 | let vault <- self.bloctoPassRef.withdrawAllUnlockedTokens() 30 | 31 | self.vaultRef.deposit(from: <- vault) 32 | } 33 | } --------------------------------------------------------------------------------