zoukankan      html  css  js  c++  java
  • [Blockchain] Cosmos Starport 101

    # 项目模板

    $ starport app github.com/hello/planet --address-prefix your_new_prefix

    项目目录结构的说明看这里: https://docs.starport.network/scaffold/project.html#directory-structure

    # 创建数据类型, 比如 post 类型, 包含有 title 和 body, 具体可查看命令帮助

    $ starport -h

    $ starport type -h

    $ starport type post title body

    含义: starport type [typeName] [field1] [field2] ... [flags]

    这是实际意义上的第一步, 为什么要这么做, 请参考这里: https://tutorials.cosmos.network/blog/tutorial/01-index.html

    Starport 进一步帮我们省去手工创建过程, 之后我们才可以进行数据的 CRUD.

    字段可以是数字和指定的类型,默认是字符串. https://docs.starport.network/scaffold/type.html#command-overview

    在 app 创建的基础模板上,starport v0.15.1 产生以下修改文件 和 新增文件:

    modified: proto/planet/genesis.proto
    modified: proto/planet/query.proto
    modified: proto/planet/tx.proto
    modified: vue/planet/store/generated/index.d.ts
    modified: vue/planet/store/generated/index.js
    modified: vue/planet/store/generated/index.ts
    modified: vue/planet/views/Types.vue
    modified: x/planet/client/cli/query.go
    modified: x/planet/client/cli/tx.go
    modified: x/planet/client/rest/rest.go
    modified: x/planet/genesis.go
    modified: x/planet/handler.go
    modified: x/planet/keeper/query.go
    modified: x/planet/module.go
    modified: x/planet/types/codec.go
    modified: x/planet/types/genesis.go
    modified: x/planet/types/genesis.pb.go
    modified: x/planet/types/keys.go
    modified: x/planet/types/query.go
    modified: x/planet/types/query.pb.go
    modified: x/planet/types/tx.pb.go

    Untracked files:

    proto/planet/posts.proto
    vue/src/store/generated/farwish/
    x/planet/client/cli/queryPosts.go
    x/planet/client/cli/txPosts.go
    x/planet/client/rest/queryPosts.go
    x/planet/client/rest/txPosts.go
    x/planet/keeper/grpc_query_posts.go
    x/planet/keeper/msg_server_posts.go
    x/planet/keeper/query_posts.go
    x/planet/keeper/posts.go
    x/planet/types/messages_posts.go
    x/planet/types/query.pb.gw.go
    x/planet/types/posts.pb.go

    # Cosmos SDK's version is: Stargate v0.40.0

    $ starport serve

    # 运行起来之后 可以使用根据模块名字而生成的 CLI 命令有 planetd.

    # https://docs.starport.network/scaffold/type.html#cli-commands

    $ planetd tx planet create-posts hello helloWorld --from=alice

    $ planetd tx planet create-posts hi helloWorld --from=bob

    $ planetd q planetd list-posts

    $ planetd tx planet delete-posts 0 --from=alice

    $ planetd tx planet delete-posts 1 --from=bob

    [Blockchain] Cosmos Starport 安装的三种方式

    [Blockchain] Cosmos Starport 地址前缀的变更方式

    Link: https://www.cnblogs.com/farwish/p/14797454.html

  • 相关阅读:
    Javaweb 第4 天xml 课程
    Javaweb 第2天 JavaScript课程
    Javaweb 第1天 HTML和CSS课程
    第27天反射(解剖)技术
    Ip 讲解
    第26 天网络编程
    第25天多线程、网络编程
    【剑指offer】连续子数组的最大和,C++实现
    [剑指offer]数组中最小的K个数,C++实现
    【剑指offer】数组中出现次数超过数组长度一半的数字,C++实现
  • 原文地址:https://www.cnblogs.com/farwish/p/14797454.html
Copyright © 2011-2022 走看看