A software development kit for writing Arbitrum Stylus smart contracts in AssemblyScript. This SDK allows developers to write, test, and deploy smart contracts to Arbitrum using familiar TypeScript-like syntax while leveraging the performance benefits of WebAssembly.
- Write smart contracts using AssemblyScript syntax
- Type-safe contract development environment
- Compatible with existing Arbitrum Stylus infrastructure
- Efficient WASM compilation
- Built-in testing utilities
- Storage abstractions for easy state management
- Node.js (v16 or later)
- npm or yarn
- Basic understanding of AssemblyScript and blockchain development
- Install the SDK:
npm install stylus-assemblyscript-sdk
- Create a new contract:
import { contract, external, view, StyledContract, Storage, U256 } from "stylus-assemblyscript-sdk";
@contract()
class SimpleStorage extends StyledContract {
private value: Storage<U256>;
constructor() {
super();
this.value = new Storage<U256>(new Uint8Array([1]));
}
@view()
getValue(): U256 {
return this.value.get();
}
@external()
setValue(newValue: U256): void {
this.value.set(newValue);
}
}
- Compile your contract:
npm run asbuild:release
stylus-assemblyscript-sdk/
├── src/
│ ├── types.ts # Core type definitions
│ ├── storage.ts # Storage abstractions
│ ├── contract.ts # Base contract class
│ └── decorators.ts # Contract decorators
├── tests/
│ └── contract.spec.ts # Test specifications
├── examples/
│ └── simple-storage.ts # Example contracts
└── assembly/
└── index.ts # Main entry point
Contracts are classes decorated with @contract()
that extend StyledContract
. They form the basic unit of deployment on Arbitrum Stylus.
The SDK provides type-safe storage abstractions for managing contract state:
private balance: Storage<U256>;
@external()
: Methods that can modify contract state@view()
: Read-only methods that don't modify state@payable()
: Methods that can receive ETH
Run the test suite:
npm test
Write a test:
import { SimpleStorage } from "../examples/simple-storage";
describe("SimpleStorage", () => {
it("should store and retrieve value", () => {
const contract = new SimpleStorage();
contract.setValue(42);
expect(contract.getValue()).toBe(42);
});
});
- Write your contract in AssemblyScript
- Test using the provided testing framework
- Compile to WASM using
asbuild
- Deploy using Stylus deployment tools
The SDK automatically handles:
- Efficient WASM compilation
- Optimal storage layouts
- Gas metering integration
Tips for optimization:
- Use appropriate data types
- Minimize storage operations
- Leverage view functions when possible
We welcome contributions! Please see our contributing guidelines for more details.
- Fork the repository
- Create a feature branch
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
This is alpha software. Use at your own risk. Always audit your contracts before deployment.
- Join our Discord
- Read the Documentation
- Report Issues
- Complete U256/I256 implementation
- Add event emission support
- Implement full ABI encoding/decoding
- Create deployment tools
- Add contract upgradeability support
This SDK is built on top of the Arbitrum Stylus platform and AssemblyScript compiler. Special thanks to the teams behind these projects.