我能要一份使用vscode的生锈合同的样板吗?只是最基本的开始。要配置代码段,我们按ctrl + shift + p,然后选择“配置用户代码段”。需要一个用于.rs和.toml文件的片段。只需按前几个字母,并准备好完整的样板。
发布于 2022-01-12 19:54:37
开始输入“近协议”以显示代码段。
关于锈蚀片段:并非所有项目都需要serde::{序列化、反序列化}。但不管怎么说,发表声明也不会有多大问题。
.toml片段:
"Near BoilerPlate Cargo.toml": {
"prefix": "near protocol",
"body": [
"",
"[lib]",
"crate-type = [\"cdylib\", \"rlib\"]",
"",
"[dependencies]",
"near-sdk = \"3.1.0\"",
"",
"[profile.release]",
"codegen-units = 1",
"# Tell `rustc` to optimize for small code size.",
"opt-level = \"z\"",
"lto = true",
"debug = false",
"panic = \"abort\"",
"overflow-checks = true",
"",
],
"description": "Boilerplate for Creating a rust near contract",
},锈片:
"NEAR BoilerPlate lib.rs": {
"prefix": "near protocol",
"body": [
"use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};",
"#[allow(unused_imports)]",
"use near_sdk::{env, near_bindgen};",
"use near_sdk::serde::{Deserialize, Serialize};",
"",
"",
"near_sdk::setup_alloc!();",
"",
"",
"#[near_bindgen]",
"#[derive(Clone, Default, Serialize, Deserialize, BorshDeserialize, BorshSerialize)]",
"#[serde(crate = \"near_sdk::serde\")]",
"pub struct Contract {",
"",
"}",
"",
"#[near_bindgen]",
"impl Contract{",
"",
"}",
],
"description": "BoilerPlate for Creating a near contract"
},https://stackoverflow.com/questions/70687641
复制相似问题