{"content":{"title":"利用Remix进行Sui Move开发","body":"### 引言\r\n除了在本地进行move合约开发，sui还提供了使用remix IDE在线编译器和WELLDONE Code进行开发，无需配置本地环境，十分便利。\r\n\r\nRemix是一种用于以太坊（Ethereum）智能合约开发的集成开发环境（IDE）。 Remix IDE 旨在提供一个方便的界面，以便开发人员能够创建、调试和部署智能合约。这对新手以及有solidity学习经验的开发者十分友好。\r\n\r\n\r\n### 添加WELLDONE Code扩展 \r\n为浏览器添加WELLDONE Code扩展  \r\nhttps://chromewebstore.google.com/detail/welldone-wallet-for-multi/bmkakpenjmcpfhhjadflneinmhboecjf?hl=zh-CN&utm_source=ext_sidebar\r\n\r\n添加后，我们创建一个新钱包\r\n\r\n![1.png](https://img.learnblockchain.cn/attachments/2024/01/8CbQDEgo65b9e27de4626.png)\r\n\r\n\r\n选择sui\r\n![2.png](https://img.learnblockchain.cn/attachments/2024/01/JhDa9r5165b9e2c833f87.png)\r\n导入已有账户的私钥\r\n\r\n![3.png](https://img.learnblockchain.cn/attachments/2024/01/LSQtBeaB65b9e2f93c577.png)\r\n\r\n如何从Sui Wallet中获得自己的私钥？步骤如下\r\n* 点击右上角的设置\r\n![4.png](https://img.learnblockchain.cn/attachments/2024/01/XDgqnRXR65b9e35282d6c.png)\r\n* 选择Security\r\n![5.png](https://img.learnblockchain.cn/attachments/2024/01/d82QYmg365b9e3dad7eb2.png)\r\n* 最下面选择Show The PrivateKey\r\n![6.png](https://img.learnblockchain.cn/attachments/2024/01/VU7tvhXB65b9e4119fc07.png)\r\n  \r\n之后我们就可以在WELLDONE Code导入sui账号\r\n\r\n![7.png](https://img.learnblockchain.cn/attachments/2024/01/jrTN2iI265b9e4607722a.png)\r\n\r\n### 添加Remix插件\r\n打开remix，下载插件，后点击插件\r\n\r\n![8.png](https://img.learnblockchain.cn/attachments/2024/01/CQtZDrKk65b9e5302f014.png)\r\n选择sui\r\n![9.png](https://img.learnblockchain.cn/attachments/2024/01/4uEiF36Y65b9e59038d03.png)\r\n连接WELLDONE Code\r\n  \r\n  \r\n  \r\n* 可能会发现无法唤起WELLDONE Code\r\n* 我们需要点击WELLDONE Code的setting 将Developer勾上\r\n\r\n![10.png](https://img.learnblockchain.cn/attachments/2024/01/KG7PHUns65b9e62848beb.png)\r\n\r\n之后我们就可以正常连接WELLDONE Code进行开发了\r\n\r\n### hello_world项目部署\r\n* 首先，创建一个空的workspace\r\n\r\n![11.png](https://img.learnblockchain.cn/attachments/2024/01/T3JvnJ9y65b9e843ea107.png)\r\n* 初始化项目,点击New Project后的Create\r\n![12.png](https://img.learnblockchain.cn/attachments/2024/01/haKRynvt65b9e8795100d.png)\r\n* 配置move.toml,在source中添加hello_world.move\r\nhello_world.move\r\n```move\r\nmodule hello_world::hello_world {\r\n    use std::string;\r\n    use sui::object::{Self, UID};\r\n    use sui::transfer;\r\n    use sui::tx_context::{Self, TxContext};\r\n\r\n    /// An object that contains an arbitrary string\r\n    struct HelloWorldObject has key, store {\r\n        id: UID,\r\n        /// A string contained in the object\r\n        text: string::String\r\n    }\r\n\r\n    public entry fun mint(ctx: &mut TxContext) {\r\n        let object = HelloWorldObject {\r\n            id: object::new(ctx),\r\n            text: string::utf8(b\"Hello World!\")\r\n        };\r\n        transfer::public_transfer(object, tx_context::sender(ctx));\r\n    }\r\n\r\n}\r\n```\r\nmove.toml\r\n```\r\n[package]\r\nname = \"hello_world\"\r\nversion = \"0.0.1\"\r\n\r\n[dependencies]\r\nSui = { git = \"https://github.com/MystenLabs/sui.git\", subdir = \"crates/sui-framework/packages/sui-framework\", rev = \"framework/devnet\" }\r\n\r\n[addresses]\r\nhello_world = \"0x0\"\r\nsui = \"0x2\"\r\n```\r\n* 回到插件界面点击编译项目\r\n\r\n![14.png](https://img.learnblockchain.cn/attachments/2024/01/kowY7Qk465b9e93e75bde.png)\r\n\r\nbuild成功\r\n\r\n![15.png](https://img.learnblockchain.cn/attachments/2024/01/xVfvnYVC65b9e950ae957.png)\r\n\r\n* 之后可以点击deploy部署  成功后左侧会有合约相关信息\r\n\r\n![16.png](https://img.learnblockchain.cn/attachments/2024/01/07Xe2vZe65b9ea67a628a.png)\r\n* 调用mint函数生成一个HelloWorldObject，交易成功后在终端输出获得交易的具体信息  \r\n\r\n![17.png](https://img.learnblockchain.cn/attachments/2024/01/eqmqNdVm65b9ea7472fcd.png)\r\n* 可以在区块链浏览器上查询到创建的obj\r\n\r\n![18.png](https://img.learnblockchain.cn/attachments/2024/01/L7m7GxpR65b9eae340a68.png)\r\n\r\n\r\n综上，我们已经成功通过remix发布了一个hello_world合约，并调用了mint函数创建了一个HelloWorldObject。\r\n\r\n相关链接：https://blog.csdn.net/Sui_Network/article/details/131077269\r\n<!--StartFragment-->\r\n\r\nMove语言学习交流QQ群: 79489587\\\r\nSui官方中文开发者电报群: https\\://t.me/sui_dev_cn\r\n\r\n<!--EndFragment-->"},"author":{"user":"https://learnblockchain.cn/people/18488","address":null},"history":"bafkreibhe3abdvjuxobaai2qbfjcyxspmlymeo7ebslutesivkjlbapofm","timestamp":1706692126,"version":1}