
In this lecture, we will talk about functions and strings in Sui Move.
You can see the public functions of any packages with explorer.

Sui Move functions have three types of visibility:
private: the default visibility of a function; it can only be accessed by functions inside the same module
public: the function is accessible by functions inside the same module, and by functions defined in another module
public(friend): the function is accessible by functions inside the same module and by functions defined in modules that are included on the module's friends list.
The return type of a function is specified in the function signature after the function parameters, separated by a colon.
A function's last line (of execution) without a semicolon is the return value.
Example:
public fun addition (a: u8, b: u8): u8 {
a + b
}
In Sui Move, entry functions are simply functions that can be called by a transactions. They must satisfy the following three requirements:
Denoted by the keyword entry
have no return value
(optional) have a mutable reference to an instance of the TxContext type in the last parameter
example:
https://github.com/seapad-fund/sui-contracts/blob/master/nft/sources/nftbox_entries.move
Entry functions typically have an instance of TxContext as the last parameter. This is a special parameter set by the Sui Move VM, and does not need to be specified by the user calling the function.
The TxContext object contains essential information about the transaction used to call the entry function, such as:
the sender's address
the signer's address
the tx's epoch, etc.
We can define our minting function in the Hello World example as the following:
public entry fun mint(ctx: &mut TxContext) {
let object = HelloWorldObject {
id: object::new(ctx),
text: string::utf8(b"Hello World!")
};
transfer::transfer(object, tx_context::sender(ctx));
}
This function simply creates a new instance of the HelloWorldObject custom type, then uses the Sui system transfer function to send it to the transaction caller.
Example:
Move does not have primitive string type, but it has a package to handle it.
module examples::strings {
use sui::object::{Self, UID};
use sui::tx_context::TxContext;
// import dependency
use std::string::{Self, String};
// an Object with a string
struct Name has key, store {
id: UID,
/// Here it is - the String type
name: String
}
// create a new Name Object with raw bytes
public fun issue_name_nft(
name_bytes: vector<u8>, ctx: &mut TxContext
): Name {
Name {
id: object::new(ctx),
name: string::utf8(name_bytes)
}
}
}
The hello world example used string as well.
public entry fun mint(ctx: &mut TxContext) {
let object = HelloWorldObject {
id: object::new(ctx),
// Here
text: string::utf8(b"Hello World!")
};
transfer::transfer(object, tx_context::sender(ctx));
}
Reference

Meet the Web3 Projects Building Smart Contracts on Bitcoin
For quite some time, the cryptocurrency ecosystem can be quickly summarized this way: you use Bitcoin to spend and store value, but you build apps that can increase this value on the Ethereum blockchain. But this year, several developers working on Bitcoin have launched breakthrough after breakthrough that would allow Bitcoin to also be the blockchain that you can use to build apps. While new features such as Ordinals and BRC-20 have gotten most of the spotlight, the Web3 movement that is wor...

Generative Art: The Next High-Value Web3 Frontier
The rise of Web3 and AI has unlocked new possibilities for the generative art genre, from new artworks and art theories to increased financial viability. Learn more about generative art and our role in shaping its future in this article. The intersection of art and technology has been a fascinating space to study and draw inspiration from. Each new innovation results in the unlocking of new ways to express oneself in the world. The Web3 industry is no stranger to this progression, especially ...

Hello, Web3!
Hello world! Created by a group of Web3 pioneers, Artech Club welcomes everyone who is ready to explore and innovate. Follow us for tips and insights on branding, marketing, and entrepreneurship. Join us in shaping the future of Web3!About usWe are members of Artech Club, dedicated to building a leading web3 education and media club. We are committed to contributing educational and valuable stories about the blockchain ecosystem and web3 world by Artech Media. We hope can deliver value and wi...
Hello world! Follow us for tips and insights on branding, marketing, and entrepreneurship. Join us in creating the future of Web3.

In this lecture, we will talk about functions and strings in Sui Move.
You can see the public functions of any packages with explorer.

Sui Move functions have three types of visibility:
private: the default visibility of a function; it can only be accessed by functions inside the same module
public: the function is accessible by functions inside the same module, and by functions defined in another module
public(friend): the function is accessible by functions inside the same module and by functions defined in modules that are included on the module's friends list.
The return type of a function is specified in the function signature after the function parameters, separated by a colon.
A function's last line (of execution) without a semicolon is the return value.
Example:
public fun addition (a: u8, b: u8): u8 {
a + b
}
In Sui Move, entry functions are simply functions that can be called by a transactions. They must satisfy the following three requirements:
Denoted by the keyword entry
have no return value
(optional) have a mutable reference to an instance of the TxContext type in the last parameter
example:
https://github.com/seapad-fund/sui-contracts/blob/master/nft/sources/nftbox_entries.move
Entry functions typically have an instance of TxContext as the last parameter. This is a special parameter set by the Sui Move VM, and does not need to be specified by the user calling the function.
The TxContext object contains essential information about the transaction used to call the entry function, such as:
the sender's address
the signer's address
the tx's epoch, etc.
We can define our minting function in the Hello World example as the following:
public entry fun mint(ctx: &mut TxContext) {
let object = HelloWorldObject {
id: object::new(ctx),
text: string::utf8(b"Hello World!")
};
transfer::transfer(object, tx_context::sender(ctx));
}
This function simply creates a new instance of the HelloWorldObject custom type, then uses the Sui system transfer function to send it to the transaction caller.
Example:
Move does not have primitive string type, but it has a package to handle it.
module examples::strings {
use sui::object::{Self, UID};
use sui::tx_context::TxContext;
// import dependency
use std::string::{Self, String};
// an Object with a string
struct Name has key, store {
id: UID,
/// Here it is - the String type
name: String
}
// create a new Name Object with raw bytes
public fun issue_name_nft(
name_bytes: vector<u8>, ctx: &mut TxContext
): Name {
Name {
id: object::new(ctx),
name: string::utf8(name_bytes)
}
}
}
The hello world example used string as well.
public entry fun mint(ctx: &mut TxContext) {
let object = HelloWorldObject {
id: object::new(ctx),
// Here
text: string::utf8(b"Hello World!")
};
transfer::transfer(object, tx_context::sender(ctx));
}
Reference

Meet the Web3 Projects Building Smart Contracts on Bitcoin
For quite some time, the cryptocurrency ecosystem can be quickly summarized this way: you use Bitcoin to spend and store value, but you build apps that can increase this value on the Ethereum blockchain. But this year, several developers working on Bitcoin have launched breakthrough after breakthrough that would allow Bitcoin to also be the blockchain that you can use to build apps. While new features such as Ordinals and BRC-20 have gotten most of the spotlight, the Web3 movement that is wor...

Generative Art: The Next High-Value Web3 Frontier
The rise of Web3 and AI has unlocked new possibilities for the generative art genre, from new artworks and art theories to increased financial viability. Learn more about generative art and our role in shaping its future in this article. The intersection of art and technology has been a fascinating space to study and draw inspiration from. Each new innovation results in the unlocking of new ways to express oneself in the world. The Web3 industry is no stranger to this progression, especially ...

Hello, Web3!
Hello world! Created by a group of Web3 pioneers, Artech Club welcomes everyone who is ready to explore and innovate. Follow us for tips and insights on branding, marketing, and entrepreneurship. Join us in shaping the future of Web3!About usWe are members of Artech Club, dedicated to building a leading web3 education and media club. We are committed to contributing educational and valuable stories about the blockchain ecosystem and web3 world by Artech Media. We hope can deliver value and wi...
Hello world! Follow us for tips and insights on branding, marketing, and entrepreneurship. Join us in creating the future of Web3.
Share Dialog
Share Dialog

Subscribe to Artech.Club

Subscribe to Artech.Club
<100 subscribers
<100 subscribers
No activity yet