diff --git a/docs-test-gen/src/main.rs b/docs-test-gen/src/main.rs
index 98763004..82a70b1f 100644
--- a/docs-test-gen/src/main.rs
+++ b/docs-test-gen/src/main.rs
@@ -8,7 +8,7 @@ use strum::{AsRefStr, EnumIter, IntoEnumIterator};
static TEMPLATES: phf::Map<&'static str, &'static str> = phf_map! {
"core" => include_str!("../templates/core.tpl"),
"execute" => include_str!("../templates/execute.tpl"),
- "instantiate-spec" => include_str!("../templates/instantiate-spec.tpl"),
+ "instantiate2-spec" => include_str!("../templates/instantiate2-spec.tpl"),
"ibc-channel" => include_str!("../templates/ibc-channel.tpl"),
"ibc-packet" => include_str!("../templates/ibc-packet.tpl"),
"storage" => include_str!("../templates/storage.tpl"),
diff --git a/docs-test-gen/templates/instantiate-spec.tpl b/docs-test-gen/templates/instantiate2-spec.tpl
similarity index 100%
rename from docs-test-gen/templates/instantiate-spec.tpl
rename to docs-test-gen/templates/instantiate2-spec.tpl
diff --git a/src/pages/core/specification/_meta.js b/src/pages/core/specification/_meta.js
index 3f526422..01170af3 100644
--- a/src/pages/core/specification/_meta.js
+++ b/src/pages/core/specification/_meta.js
@@ -1,3 +1,3 @@
export default {
- "instantiate2-algo": "Instantiate2 Algorithm",
+ "instantiate2-algo": "Instantiate2 algorithm",
};
diff --git a/src/pages/core/specification/instantiate2-algo.mdx b/src/pages/core/specification/instantiate2-algo.mdx
index ea537deb..58125e19 100644
--- a/src/pages/core/specification/instantiate2-algo.mdx
+++ b/src/pages/core/specification/instantiate2-algo.mdx
@@ -1,9 +1,12 @@
---
-tags: ["core", "specification"]
+tags: ["core", "specification", "instantiate2"]
---
import { Callout } from "nextra/components";
+[instantiate2_address]:
+ https://docs.rs/cosmwasm-std/latest/cosmwasm_std/fn.instantiate2_address.html
+
# Instantiate2 algorithm
With the instantiate2 algorithm you can create a contract address in a predictable and deterministic
@@ -13,18 +16,17 @@ We use SHA-256 as the underlying hashing algorithm.
You need to provide the following inputs:
-- Checksum: This is the checksum of the contract code (the Wasm module, for example). This _has_ to
- be a SHA-256 hash
-- Creator: This is the canonicalized address of the user instantiating the contract
-- Salt: This is some byte string allowing you to distinguish multiple instantiations of the same
- contract by the same creator; this parameter has to be under 64 bytes in length
-- Message: This is usually unused. CosmWasm sets this to an empty byte string
+- **checksum**: this is the checksum of the contract code (the Wasm module, for example); this
+ **has** to be a SHA-256 hash,
+- **creator**: this is the canonicalized address of the user instantiating the contract,
+- **salt**: this is some byte string allowing you to distinguish multiple instantiations of the same
+ contract by the same creator; this parameter has to be under 64 bytes in length,
+- **msg**: the initialization message is usually unused; CosmWasm sets this to an empty byte string.
-
- Make sure you convert all the integers into their *big-endian* byte representation!
-
+Assuming that the macro `concat!{:rust}` joins two byte slices and the function `hash_sha256{:rust}`
+returns the SHA-256 hash of the provided input, the Instantiate2 algorithm would look like this:
-```rust filename="instantiate2.rs" template="instantiate-spec"
+```rust filename="instantiate2.rs" template="instantiate2-spec"
let c_checksum = concat!((checksum.len() as u64).to_be_bytes(), checksum);
let c_creator = concat!((creator.len() as u64).to_be_bytes(), creator);
let c_salt = concat!((salt.len() as u64).to_be_bytes(), salt);
@@ -41,3 +43,8 @@ let canonical_address = hash_sha256(
),
);
```
+
+
+ Please note that an implementation of this [function][instantiate2_address] is already
+ available for you to use, just add the import: `use cosmwasm_std::instantiate2_address;{:rust}`
+