-
Notifications
You must be signed in to change notification settings - Fork 224
Record contract id into abi and manifest files. #540
Comments
It's required only if we want to know it inside the smart contract |
Agree, we can convert from private JObject GetStorage(JArray _params)
{
UInt160 script_hash = UInt160.Parse(_params[0].AsString());
Int id = GetContractIdByScriptHash(script_hash); // <---- add this line
byte[] key = _params[1].AsString().HexToBytes();
StorageItem item = Blockchain.Singleton.View.Storages.TryGet(new StorageKey
{
Id = id,
Key = key
}) ?? new StorageItem();
return item.Value?.ToHexString();
} |
@shargon One example: |
We can add a new RPC command for get this information |
getcontractstate can do this. |
Then we don't need to change the core, right? |
I just worry about if a contract was updated and the id was not recorded, how to find the new one. |
I think @Tommo-L 's code is enough, it has no impact on the user's use, just adjust the implementation logic of RPC |
OK, I'll close this. |
Now contract id is used to be storage key for smart contract. However if someone wants to get storage content, he has to invoke RPC method [getcontractstate] to get id. This is very inconvenient for developers to test contracts. My advice is to write id as a parameter into abi and manifest files whenever it's successfully deployed. This is much more conveninet.
The text was updated successfully, but these errors were encountered: