Skip to content

Commit

Permalink
chore: remove metahash
Browse files Browse the repository at this point in the history
  • Loading branch information
shamilsan committed Jul 12, 2023
1 parent 055b3ad commit fd4a5d0
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 36 deletions.
14 changes: 0 additions & 14 deletions docs/developing-contracts/metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,3 @@ As a result of the smart-contract compilation, a `meta.txt` file will be generat
```
01000000000103000000010500000001090000000102000000010d000000010f0000000111000000000112000000a9094c00083064656d6f5f6d6574615f696f344d657373616765496e6974496e0000080118616d6f756e74040108753800012063757272656e6379080118537472696e6700000400000503000800000502000c083064656d6f5f6d6574615f696f384d657373616765496e69744f7574000008013465786368616e67655f72617465100138526573756c743c75382c2075383e00010c73756d04010875380000100418526573756c740804540104044501040108084f6b040004000000000c457272040004000001000014083064656d6f5f6d6574615f696f244d657373616765496e000004010869641801084964000018083064656d6f5f6d6574615f696f084964000008011c646563696d616c1c010c75363400010c68657820011c5665633c75383e00001c000005060020000002040024083064656d6f5f6d6574615f696f284d6573736167654f7574000004010c7265732801384f7074696f6e3c57616c6c65743e00002804184f7074696f6e040454012c0108104e6f6e6500000010536f6d6504002c00000100002c083064656d6f5f6d6574615f696f1857616c6c6574000008010869641801084964000118706572736f6e300118506572736f6e000030083064656d6f5f6d6574615f696f18506572736f6e000008011c7375726e616d65080118537472696e670001106e616d65080118537472696e6700003400000238003800000504003c083064656d6f5f6d6574615f696f384d6573736167654173796e63496e0000040114656d707479400108282900004000000400004404184f7074696f6e04045401040108104e6f6e6500000010536f6d650400040000010000480000022c00
```

## Verify metadata

To make it possible to verify metadata for a program, you can use the `metahash()` function. It allows verifying metadata on-chain.

```rust
#[no_mangle]
// It returns the Hash of metadata.
// .metahash is generating automatically while you are using build.rs
extern "C" fn metahash() {
let metahash: [u8; 32] = include!("../.metahash");
msg::reply(metahash, 0).expect("Failed to share metahash");
}
```
8 changes: 0 additions & 8 deletions docs/examples/ping.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ extern "C" fn state() {
);
}
```
- `metahash()` function that returns the metadata hash:
```rust
#[no_mangle]
extern "C" fn metahash() {
reply(include!("../.metahash"))
.expect("Failed to encode or reply with `[u8; 32]` from `metahash()`");
}
```

The `lib.rs` file in the `src` directory contains the following code:
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,3 @@ fn main() {
```
01000000000103000000010500000001090000000102000000010d000000010f0000000111000000000112000000a9094c00083064656d6f5f6d6574615f696f344d657373616765496e6974496e0000080118616d6f756e74040108753800012063757272656e6379080118537472696e6700000400000503000800000502000c083064656d6f5f6d6574615f696f384d657373616765496e69744f7574000008013465786368616e67655f72617465100138526573756c743c75382c2075383e00010c73756d04010875380000100418526573756c740804540104044501040108084f6b040004000000000c457272040004000001000014083064656d6f5f6d6574615f696f244d657373616765496e000004010869641801084964000018083064656d6f5f6d6574615f696f084964000008011c646563696d616c1c010c75363400010c68657820011c5665633c75383e00001c000005060020000002040024083064656d6f5f6d6574615f696f284d6573736167654f7574000004010c7265732801384f7074696f6e3c57616c6c65743e00002804184f7074696f6e040454012c0108104e6f6e6500000010536f6d6504002c00000100002c083064656d6f5f6d6574615f696f1857616c6c6574000008010869641801084964000118706572736f6e300118506572736f6e000030083064656d6f5f6d6574615f696f18506572736f6e000008011c7375726e616d65080118537472696e670001106e616d65080118537472696e6700003400000238003800000504003c083064656d6f5f6d6574615f696f384d6573736167654173796e63496e0000040114656d707479400108282900004000000400004404184f7074696f6e04045401040108104e6f6e6500000010536f6d650400040000010000480000022c00
```

## 验证元数据

为了验证程序的元数据,可以使用`metahash()`函数。它允许在链上验证元数据。

```rust
#[no_mangle]
// It returns the Hash of metadata.
// .metahash is generating automatically while you are using build.rs
extern "C" fn metahash() {
let metahash: [u8; 32] = include!("../.metahash");
msg::reply(metahash, 0).expect("Failed to share metahash");
}
```

0 comments on commit fd4a5d0

Please sign in to comment.