You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix outdated Address and token APIs in EVM deployment migration guide (#2689)
* Fix outdated Address and token APIs in EVM deployment migration guide
### What
Replace the removed `Address::random` call with `Address::generate`, update the quoted token-interface `approve` parameter name, bump the pinned soroban-sdk version, and point the example clone at a current ref.
### Why
`Address::random` no longer exists in the SDK and the quoted parameter name was renamed, so a reader following this migration guide would hit compile errors and copy an incorrect interface.
* Align vault guide with the current soroban-examples token contract
Pointing the clone at `main` (previous commit) changes the token contract's
ABI, so the surrounding guide needed to follow:
- The token sets its admin and metadata in `__constructor`; there is no
`initialize` method. `create_contract` now passes those through
`deploy_v2`, the vault's `initialize` builds them with `String::from_str`,
and the quoted interface declares `__constructor` as an inherent function
on the contract type rather than a trait method (it cannot live in a trait
impl, and needs no "already initialized" guard).
- The `initialize_token.sh` script is gone. Its arguments move onto
`stellar contract deploy` after the `--`, so the token is deployed and
initialized in one transaction.
- `transfer`'s destination is now a `MuxedAddress`, resolved with
`.address()` before touching balances. Call sites are unchanged: the
generated client takes `impl Into<MuxedAddress>`, and `MuxedAddress`
implements `From<&Address>`.
- `stellar contract install` is deprecated in favour of `contract upload`.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Elliot <elliot@stellar.org>
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
git clone -b main https://github.com/stellar/soroban-examples
195
195
```
196
196
197
197
Then, navigate to the `soroban-examples/token` directory
@@ -254,11 +254,11 @@ publish = false
254
254
crate-type = ["cdylib"]
255
255
256
256
[dependencies]
257
-
soroban-sdk = { version = "26" }
257
+
soroban-sdk = { version = "27" }
258
258
num-integer = { version = "0.1.45", default-features = false, features = ["i128"] }
259
259
260
260
[dev-dependencies]
261
-
soroban-sdk = { version = "26", features = ["testutils"] }
261
+
soroban-sdk = { version = "27", features = ["testutils"] }
262
262
263
263
[profile.release]
264
264
opt-level = "z"
@@ -281,7 +281,7 @@ In this project we will need to create 3 files:
281
281
-`src/test.rs` - This is where we will write our tests.
282
282
-`src/token.rs` - This is file inherits the token contact that we imported earlier. It's also where we will write our token creation logic.
283
283
284
-
To interact with the token contract, we'll use a built in interface that you can find in the `token_interface.rs` tab. This interface includes the `initialize`and `mint`functions that we will use to create and mint tokens for us to use in our vault contract. If you want to see the full code of the token contract, you can check it out [here](https://github.com/stellar/soroban-examples/tree/main/token/src).
284
+
To interact with the token contract, we'll use a built in interface that you can find in the `token_interface.rs` tab. The token sets its admin and metadata in a `__constructor` function, which the host runs as part of the deployment itself, and exposes a `mint`function that we will use to mint tokens for our vault contract. Because the constructor runs at deployment, there is no separate initialization call to make — or to front-run. If you want to see the full code of the token contract, you can check it out [here](https://github.com/stellar/soroban-examples/tree/main/token/src).
@@ -1106,38 +1115,27 @@ First, we need to build the vault contract. We can do this by running the `build
1106
1115
stellar contract build
1107
1116
```
1108
1117
1109
-
Next, we need to deploy the token contract. We can do this by running the `deploy_token.sh` script.
1118
+
Next, we need to deploy the token contract. We can do this by running the `deploy_token.sh` script. The arguments after the `--` are the token's constructor arguments, so this single command both deploys the token and sets its admin and metadata.
--network-passphrase 'Test SDF Network ; September 2015' \
1133
1126
-- \
1134
-
initialize \
1135
1127
--admin <USER_ADDRESS> \
1136
1128
--decimal 18 \
1137
1129
--name <TOKEN_NAME> \
1138
1130
--symbol <TOKEN_SYMBOL>
1139
1131
```
1140
1132
1133
+
We should receive an output with the token contract ID. We will need this ID for the next step. There is no follow-up initialization call — the constructor already ran.
0 commit comments