Using Code Pointers/Code Collections
Using Code Pointers
A code pointer is a reference to an already existing piece of code. Any source code already existing at an address is called a "code collection". A code collection is simply a bundle of contract source code that has already been uploaded to STRATO via a contract Upload or chain creation. It can be reused as the source code for another contract to be instantiated. Referencing another code collection points to the already uploaded and parsed code as the source code for this new contract. The newly instantiated contract can be specified from the contracts in the collection independently of the one originally used.
As a security measure, code collections can only be used as the Governance contracts of private shards and cannot be arbitrarily used in any contract upload. Note however that the governance contract may go ahead to use the source code from the code collection and instantiate contracts on the private shard.
New contracts instantiated from code pointers to code collections retain the organizational namespacing of the original code uploader, rather than the organization of the current creator.
Developers may take advantage of this by including all of their Dapp’s source code in the initial Dapp Privacy Realm creation API call. Then when a new Asset Shard needs to be created, it can reference the <address>:<shardId>
of the Dapp Realm, and the contract name of the asset contract. This way every query insertion into Cirrus by transactions in your app uses the same naming, rather than disparate ones. Your app may now query Cirrus using the prefix of whatever organization initially created the Dapp (most likely your own organization), and the name of the contract instantiated in the original code collection.
For more information and examples, visit the Code Pointer Documentation.