A comprehensive SUI blockchain library for Internet Computer (IC) built in Motoko. This library provides essential tools for working with SUI addresses, transactions, and blockchain operations within the IC ecosystem.
- Address Management: Generate, validate, and normalize SUI addresses
- Transaction Building: Create and manage SUI transactions (transfers, move calls, etc.)
- Type Definitions: Complete type system for SUI blockchain objects
- Utilities: Helper functions for common operations
# Install Mops if not already installed
npm i -g ic-mops
# Add the SUI package to your project
mops add suigit clone <repository-url>
cd sui
mops install
dfx start --background
dfx deployimport Sui "mo:sui";
// Validate a SUI address
let isValid = Sui.Address.isValidAddress("0x1234567890abcdef1234567890abcdef12345678");
// Create a simple transaction
let gasData = {
payment = [];
owner = "0x1234567890abcdef1234567890abcdef12345678";
price = 1000;
budget = 10000;
};
let txData = Sui.Transaction.createTransferTransaction(
"0x1234567890abcdef1234567890abcdef12345678", // sender
"0xabcdef1234567890abcdef1234567890abcdef12", // recipient
[], // objects to transfer
gasData
);Core type definitions for SUI blockchain objects:
SuiAddress- SUI address typeObjectRef- Object reference typeTransactionData- Transaction data structureCommand- Transaction command variants- And many more...
Address validation and manipulation:
isValidAddress()- Validate SUI address formatnormalizeAddress()- Normalize address formatpublicKeyToAddress()- Generate address from public key
Transaction creation and management:
createTransferTransaction()- Create transfer transactionscreateMoveCallTransaction()- Create move call transactionssignTransaction()- Sign transactions (placeholder)
Utility functions:
bytesToHex()- Convert bytes to hex stringhashText()- Simple text hashing- String manipulation functions
import Sui "mo:sui";
public func validateAddress(address : Text) : Bool {
Sui.Address.isValidAddress(address)
}import Sui "mo:sui";
public func createSampleTx(sender : Text) : Sui.Types.TransactionData {
let gasData = {
payment = [];
owner = sender;
price = 1000;
budget = 10000;
};
Sui.Transaction.createTransferTransaction(sender, recipient, [], gasData)
}# Start the replica
dfx start --background
# Deploy canisters
dfx deploy
# Run tests
mops testsrc/
├── lib.mo # Main library entry point
├── types.mo # Type definitions
├── address.mo # Address utilities
├── transaction.mo # Transaction builder
├── utils.mo # Utility functions
└── sui_backend/
└── main.mo # Example canister
test/
└── lib.test.mo # Tests
This project is licensed under the MIT License - see the LICENSE file for details.