使用smartpy撰寫tezos的nft程式

撰寫nft合約

import smartpy as sp
FA2 = sp.io.import_template("FA2.py")

class NFT(FA2.FA2):
   pass

@sp.add_test(name="tests")
def test():
  jerry = sp.test_account("Jerry")
  tom = sp.test_account("Tom")
  admin = sp.address("tz1aV2DuPYXEK2mEVc4VBhP9o4gguFGxBky4")
  scenario = sp.test_scenario()
  scenario.h1("tutorial tests")
  nft = NFT(FA2.FA2_config(non_fungible=True), admin=admin, metadata= sp.utils.metadata_of_url("https://alanhc.github.io/nft/tezos-contract-example.json")
  scenario += nft

部署合約

  • 更改admin為自己的地址、按下執行(左上),並按下deploy contract https://i.imgur.com/qLG96GS.png
  • 選擇測試鏈(ghostnet),並選擇estimate gas https://i.imgur.com/tRzRx3P.png https://i.imgur.com/BEyHnAN.png
  • 將 token metadata (hex) 輸入,可使用 string2hex
    • 範例:(hex)697066733a2f2f6261666b7265696833366d336434796662707974656c75766e7475706835787962777467786476796b736267796736366573343464726b34687179,原文(string):ipfs://bafkreih36m3d4yfbpyteluvntuph5xybwtgxdvyksbgyg66es44drk4hqy https://i.imgur.com/5W1GHKA.png

查看nft

  • tzkt >balance 查看是否有nft https://i.imgur.com/vhoA46K.png

參考

在solana上mint NFT

  1. 下載 solana cli: sh -c "$(curl -sSfL https://release.solana.com/v1.14.11/install)"

  2. 新增帳號 solana-keygen new --outfile ~/.config/solana/devnet.json

  3. 設定 devnet solana config set --url <https://metaplex.devnet.rpcpool.com/>

  4. 檢查設定 solana config get

    Config File: ~/.config/solana/cli/config.yml
    RPC URL: https://metaplex.devnet.rpcpool.com/
    WebSocket URL: wss://metaplex.devnet.rpcpool.com/ (computed)
    Keypair Path: ~/.config/solana/devnet.json
    Commitment: confirmed
  5. 拿測試token: solana airdrop 2

  6. sugar launch

2022 10 03 10 09

2022 09 19 09 25

9/19

  • Securify: Practical security analysis of smart contracts
  • Smart contracts: security patterns in the ethereum ecosystem and solidity
  • Empirical vulnerability analysis of automated smart contracts security testing on blockchains
  • A survey of security vulnerabilities in ethereum smart contracts
  • Scalable and Privacy-Preserving Design of On/Off-Chain Smart Contracts
  • zk-AuthFeed: Protecting Data Feed to Smart Contracts with Authenticated Zero Knowledge Proof
  • A Secure and Authenticated Mobile Payment Protocol Against Off-Site Attack Strategy

9/23

0%