Explanation of Starcoin Contract Account

* By Starcoin community

From Ethereum's Contract Account

Starcoin's Contract Account

Starcoin's contract account

// SignerDelegated can only be stored under address, not in other structs.
struct SignerDelegated has key {}
// SignerCapability can only be stored in other structs, not under address.
// So that the capability is always controlled by contracts, not by some EOA.
struct SignerCapability has store { addr: address }

public fun is_signer_delegated(addr: address): bool {
exists<SignerDelegated>(addr)
}

native fun create_signer(addr: address): signer;
       struct GenesisSignerCapability has key {
cap: Account::SignerCapability,
}

public(friend) fun get_genesis_signer(): signer acquires GenesisSignerCapability {
let cap = borrow_global<GenesisSignerCapability>(CoreAddresses::GENESIS_ADDRESS());
Account::create_signer_with_cap(&cap.cap)
}

Conclusion

--

--

Starcoin is a proof-of-work blockchain that enables secure smart contracts based on Move to power services in Web 3.0

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Starcoin

Starcoin is a proof-of-work blockchain that enables secure smart contracts based on Move to power services in Web 3.0