安装 flow-cli,MacOS 需要下载最新版本的二进制文件,brew 只能安装旧版本。具体安装方法见文档 Install the Flow CLI,该文档使用版本是 v0.25.0。
生成key-pair
1 2 3 4 5
$ flow keys generate --sig-algo=ECDSA_secp256k1
Store private key safely and don't share with anyone! Private Key 11e67f5360e61d7d92eb73e1dc48ffbd71c55c8bdf727520d11ddfa6db63554d Public Key cd23c71391d33c23c867319258ad6cd082b0066e564e23d3fda3c4e5b9ec841eaaa07d2189965130445a4edda244720628334f6a879d80220b573d9914edcbe2
创建testnet flow地址
访问页面:Flow Testnet Faucet ,创建地址。填入生成的 public key,选择ECDSA_secp256k1签名算法和SHA3_256(和 ETH 哈希算法相同)哈希算法。
$ cat > tx.cdc <<EOF import FungibleToken from 0x9a0766d93b6608b7 import FlowToken from 0x7e60df042a9c0868
transaction(amount: UFix64, to: Address) {
// The Vault resource that holds the tokens that are being transferred let sentVault: @FungibleToken.Vault
prepare(signer: AuthAccount) {
// Get a reference to the signer's stored vault let vaultRef = signer.borrow<&FlowToken.Vault>(from: /storage/flowTokenVault) ?? panic("Could not borrow reference to the owner's Vault!")
// Withdraw tokens from the signer's stored vault self.sentVault <- vaultRef.withdraw(amount: amount) }
execute {
// Get a reference to the recipient's Receiver let receiverRef = getAccount(to) .getCapability(/public/flowTokenReceiver) .borrow<&{FungibleToken.Receiver}>() ?? panic("Could not borrow receiver reference to the recipient's Vault")
// Deposit the withdrawn tokens in the recipient's receiver receiverRef.deposit(from: <-self.sentVault) } } EOF
Sending transaction with ID: 8a979bd7d0278bada8b9cf57611608a5ba258090ecdddaaa83e2e5d04fe53af7
Status ✅ SEALED ID 8a979bd7d0278bada8b9cf57611608a5ba258090ecdddaaa83e2e5d04fe53af7 Payer 25470ac6e0585a62 Authorizers [25470ac6e0585a62]
Proposal Key: Address 25470ac6e0585a62 Index 0 Sequence 0
No Payload Signatures
Envelope Signature 0: 25470ac6e0585a62 Signatures (minimized, use --include signatures)
Events: Index 0 Type A.7e60df042a9c0868.FlowToken.TokensWithdrawn Tx ID 8a979bd7d0278bada8b9cf57611608a5ba258090ecdddaaa83e2e5d04fe53af7 Values - amount (UFix64): 1.00000000 - from (Address?): 0x25470ac6e0585a62
Index 1 Type A.7e60df042a9c0868.FlowToken.TokensDeposited Tx ID 8a979bd7d0278bada8b9cf57611608a5ba258090ecdddaaa83e2e5d04fe53af7 Values - amount (UFix64): 1.00000000 - to (Address?): 0x72aeca95731d54e5
Index 2 Type A.7e60df042a9c0868.FlowToken.TokensWithdrawn Tx ID 8a979bd7d0278bada8b9cf57611608a5ba258090ecdddaaa83e2e5d04fe53af7 Values - amount (UFix64): 0.00010000 - from (Address?): 0x25470ac6e0585a62
Index 3 Type A.7e60df042a9c0868.FlowToken.TokensDeposited Tx ID 8a979bd7d0278bada8b9cf57611608a5ba258090ecdddaaa83e2e5d04fe53af7 Values - amount (UFix64): 0.00010000 - to (Address?): 0x912d5440f7e3769e
Index 4 Type A.912d5440f7e3769e.FlowFees.TokensDeposited Tx ID 8a979bd7d0278bada8b9cf57611608a5ba258090ecdddaaa83e2e5d04fe53af7 Values - amount (UFix64): 0.00010000