Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8252f19
add the stablecoin contract type to stellar readme
ElliotFriend Nov 7, 2025
195aabf
add a new `ConstructorArgument` type to the contract builder
ElliotFriend Nov 7, 2025
9f3a60c
create a command to print the deploy CLI command with constructor
ElliotFriend Nov 7, 2025
ea78063
add values for the deploy command in fungible token
ElliotFriend Nov 7, 2025
0d317eb
print deploy command on non-fungible contract
ElliotFriend Nov 7, 2025
c71c4a7
add a placeholder for premint recipient in deploy command
ElliotFriend Nov 7, 2025
d25c3cd
add deploy command placeholder addresses in access control
ElliotFriend Nov 7, 2025
0614fb8
fix linting warning in print.ts file
ElliotFriend Nov 7, 2025
7d7e0b0
include all constructor arguments in export functionality
ElliotFriend Nov 7, 2025
019d4c5
update test snapshots
ElliotFriend Nov 7, 2025
55f90cb
parameterize base uri for stellar nft contracts
ElliotFriend Nov 8, 2025
770bdd8
more consistent placholder address formats
ElliotFriend Nov 10, 2025
7189fe0
be more consistent with "baseUri" instead of "uri"
ElliotFriend Nov 10, 2025
d5a36af
remove token uri parameterization
ElliotFriend Nov 11, 2025
5c65037
remove base uri input in Stellar ui
ElliotFriend Nov 12, 2025
d3266b3
remove baseuri description for mcp server
ElliotFriend Nov 12, 2025
7818a8c
add changeset
ElliotFriend Nov 12, 2025
058ee1d
Merge branch 'master' of https://github.com/OpenZeppelin/contracts-wi…
ElliotFriend Nov 12, 2025
222d72c
Merge branch 'master' into feat/stellar-use-constructor
CoveMB Nov 12, 2025
7538724
remove baseuri field from non-fungible compilation test
ElliotFriend Nov 12, 2025
ac86ba7
Merge remote-tracking branch 'origin/master' into feat/stellar-use-co…
CoveMB Nov 13, 2025
3501b49
Merge token url
CoveMB Nov 13, 2025
4ee8914
Align exemple url with other languages
CoveMB Nov 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/big-buttons-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@openzeppelin/wizard-stellar': minor
---

Use constructor args for Sellar smart contracts
1 change: 1 addition & 0 deletions packages/core/stellar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ This package provides a programmatic API. For a web interface, see https://wizar
The following contract types are supported:
- `fungible`
- `nonFungible`
- `stablecoin`

Each contract type has functions/constants as defined below.

Expand Down
10 changes: 7 additions & 3 deletions packages/core/stellar/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface Contract {
name: string;
useClauses: UseClause[];
constructorCode: string[];
constructorArgs: Argument[];
constructorArgs: ConstructorArgument[];
implementedTraits: TraitImplBlock[];
freeFunctions: ContractFunction[];
variables: Variable[];
Expand Down Expand Up @@ -71,6 +71,10 @@ export interface Argument {
type?: string;
}

export interface ConstructorArgument extends Argument {
value?: string;
}

export class ContractBuilder implements Contract {
readonly name: string;
license = 'MIT';
Expand All @@ -79,7 +83,7 @@ export class ContractBuilder implements Contract {

readonly documentations: string[] = [];

readonly constructorArgs: Argument[] = [];
readonly constructorArgs: ConstructorArgument[] = [];
readonly constructorCode: string[] = [];

private implementedTraitsMap: Map<string, TraitImplBlock> = new Map();
Expand Down Expand Up @@ -241,7 +245,7 @@ export class ContractBuilder implements Contract {
existingFn.tags = [...(existingFn.tags ?? []), tag];
}

addConstructorArgument(arg: Argument): void {
addConstructorArgument(arg: ConstructorArgument): void {
for (const existingArg of this.constructorArgs) {
if (existingArg.name == arg.name) {
return;
Expand Down
173 changes: 146 additions & 27 deletions packages/core/stellar/src/fungible.test.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,15 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK␊
pub fn __constructor(e: &Env, name: String, symbol: String) {␊
Base::set_metadata(e, 18, name, symbol);␊
}␊
}␊
Expand Down Expand Up @@ -51,8 +58,15 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK␊
pub fn __constructor(e: &Env, name: String, symbol: String) {␊
Base::set_metadata(e, 18, name, symbol);␊
}␊
}␊
Expand Down Expand Up @@ -91,8 +105,16 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK \\␊
// --owner <owner_address>␊
pub fn __constructor(e: &Env, name: String, symbol: String, owner: Address) {␊
Base::set_metadata(e, 18, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
}␊
Expand Down Expand Up @@ -158,8 +180,16 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK \\␊
// --owner <owner_address>␊
pub fn __constructor(e: &Env, name: String, symbol: String, owner: Address) {␊
Base::set_metadata(e, 18, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
}␊
Expand Down Expand Up @@ -240,9 +270,18 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, recipient: Address) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
Base::mint(e, &recipient, 1000000000000000000000);␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK \\␊
// --recipient <recipient_address> \\␊
// --premint 1000000000000000000000␊
pub fn __constructor(e: &Env, name: String, symbol: String, recipient: Address, premint: i128) {␊
Base::set_metadata(e, 18, name, symbol);␊
Base::mint(e, &recipient, premint);␊
}␊
}␊
Expand Down Expand Up @@ -271,8 +310,15 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK␊
pub fn __constructor(e: &Env, name: String, symbol: String) {␊
Base::set_metadata(e, 18, name, symbol);␊
}␊
}␊
Expand Down Expand Up @@ -301,8 +347,15 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK␊
pub fn __constructor(e: &Env, name: String, symbol: String) {␊
Base::set_metadata(e, 18, name, symbol);␊
}␊
}␊
Expand Down Expand Up @@ -332,8 +385,16 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, owner: Address) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK \\␊
// --owner <owner_address>␊
pub fn __constructor(e: &Env, name: String, symbol: String, owner: Address) {␊
Base::set_metadata(e, 18, name, symbol);␊
ownable::set_owner(e, &owner);␊
}␊
}␊
Expand Down Expand Up @@ -372,8 +433,16 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, admin: Address) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK \\␊
// --admin <admin_address>␊
pub fn __constructor(e: &Env, name: String, symbol: String, admin: Address) {␊
Base::set_metadata(e, 18, name, symbol);␊
access_control::set_admin(e, &admin);␊
}␊
}␊
Expand Down Expand Up @@ -413,9 +482,26 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
pub fn __constructor(e: &Env, recipient: Address, owner: Address) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
Base::mint(e, &recipient, 2000000000000000000000);␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK \\␊
// --recipient <recipient_address> \\␊
// --premint 2000000000000000000000 \\␊
// --owner <owner_address>␊
pub fn __constructor(␊
e: &Env,␊
name: String,␊
symbol: String,␊
recipient: Address,␊
premint: i128,␊
owner: Address,␊
) {␊
Base::set_metadata(e, 18, name, symbol);␊
Base::mint(e, &recipient, premint);␊
ownable::set_owner(e, &owner);␊
}␊
Expand Down Expand Up @@ -506,16 +592,32 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl MyToken {␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name MyToken \\␊
// --symbol MTK \\␊
// --recipient <recipient_address> \\␊
// --premint 2000000000000000000000 \\␊
// --admin <admin_address> \\␊
// --pauser <pauser_address> \\␊
// --upgrader <upgrader_address> \\␊
// --minter <minter_address>␊
pub fn __constructor(␊
e: &Env,␊
name: String,␊
symbol: String,␊
recipient: Address,␊
premint: i128,␊
admin: Address,␊
pauser: Address,␊
upgrader: Address,␊
minter: Address,␊
) {␊
Base::set_metadata(e, 18, String::from_str(e, "MyToken"), String::from_str(e, "MTK"));␊
Base::mint(e, &recipient, 2000000000000000000000);␊
Base::set_metadata(e, 18, name, symbol);␊
Base::mint(e, &recipient, premint);␊
access_control::set_admin(e, &admin);␊
access_control::grant_role_no_auth(e, &admin, &pauser, &Symbol::new(e, "pauser"));␊
access_control::grant_role_no_auth(e, &admin, &upgrader, &Symbol::new(e, "upgrader"));␊
Expand Down Expand Up @@ -616,9 +718,26 @@ Generated by [AVA](https://avajs.dev).
#[contractimpl]␊
impl CustomToken {␊
pub fn __constructor(e: &Env, recipient: Address, owner: Address) {␊
Base::set_metadata(e, 18, String::from_str(e, "Custom $ Token"), String::from_str(e, "MTK"));␊
Base::mint(e, &recipient, 2000000000000000000000);␊
// deploy this smart contract with the Stellar CLI:␊
//␊
// stellar contract deploy \\␊
// --wasm path/to/file.wasm \\␊
// -- \\␊
// --name "Custom $ Token" \\␊
// --symbol MTK \\␊
// --recipient <recipient_address> \\␊
// --premint 2000000000000000000000 \\␊
// --owner <owner_address>␊
pub fn __constructor(␊
e: &Env,␊
name: String,␊
symbol: String,␊
recipient: Address,␊
premint: i128,␊
owner: Address,␊
) {␊
Base::set_metadata(e, 18, name, symbol);␊
Base::mint(e, &recipient, premint);␊
ownable::set_owner(e, &owner);␊
}␊
Expand Down
Binary file modified packages/core/stellar/src/fungible.test.ts.snap
Binary file not shown.
9 changes: 6 additions & 3 deletions packages/core/stellar/src/fungible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export function buildFungible(opts: FungibleOptions): ContractBuilder {

function addBase(c: ContractBuilder, name: string, symbol: string, pausable: boolean) {
// Set metadata
c.addConstructorCode(`Base::set_metadata(e, 18, String::from_str(e, "${name}"), String::from_str(e, "${symbol}"));`);
c.addConstructorArgument({ name: 'name', type: 'String', value: name });
c.addConstructorArgument({ name: 'symbol', type: 'String', value: symbol });
c.addConstructorCode('Base::set_metadata(e, 18, name, symbol);');

// Set token functions
c.addUseClause('stellar_tokens::fungible', 'Base');
Expand Down Expand Up @@ -198,8 +200,9 @@ function addPremint(c: ContractBuilder, amount: string) {

c.addUseClause('soroban_sdk', 'Address');

c.addConstructorArgument({ name: 'recipient', type: 'Address' });
c.addConstructorCode(`Base::mint(e, &recipient, ${premintAbsolute});`);
c.addConstructorArgument({ name: 'recipient', type: 'Address', value: '<recipient_address>' });
c.addConstructorArgument({ name: 'premint', type: 'i128', value: String(premintAbsolute) });
c.addConstructorCode(`Base::mint(e, &recipient, premint);`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/stellar/src/generate/non-fungible.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const booleans = [true, false];
const blueprint = {
name: ['MyToken'],
symbol: ['MTK'],
tokenUri: ['https://www.mytoken.com'],
tokenUri: ['https://example.com'],
burnable: booleans,
pausable: booleans,
upgradeable: booleans,
Expand Down
Loading
Loading