Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable creating AssetIds from ContactIds and SubIds #1354

Open
bitzoic opened this issue May 2, 2024 · 0 comments
Open

Enable creating AssetIds from ContactIds and SubIds #1354

bitzoic opened this issue May 2, 2024 · 0 comments

Comments

@bitzoic
Copy link
Member

bitzoic commented May 2, 2024

Currently there is no way to get an AssetId if you have a ContractId and a SubId. This means if you mint an asset from a contract, you do not know the AssetId of what you just minted. Something similar to this needs to be added to the rust SDK:

pub fn get_asset_id(sub_id: Bytes32, contract: ContractId) -> AssetId {
    let mut hasher = Sha256::new();
    hasher.update(*contract);
    hasher.update(*sub_id);
    AssetId::new(*Bytes32::from(<[u8; 32]>::from(hasher.finalize())))
}

Documentation on this should also be included in the AssetId section of the book

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant