基于Ownable contract在 testnet 上用不同的钱包(argent 和 braavos)部署 2 个智能合约。将合约所有权从 argent 钱包账户转移到 braavos 账户。与 dispatcher 交互,从智能合约 1 调用智能合约 2 的数据。
基于 Ownable contract,在 testnet 上用不同的钱包(argent 和 braavos)部署 2 个智能合约。将合约所有权从 argent 钱包账户转移到 braavos 账户。与 dispatcher 交互,从智能合约 1 调用智能合约 2 的数据。
钱包 | 地址 |
---|---|
Argent | 0x05E51CAF456A394D4ED02c4e0f373d8A162851c492d382F74822b10AaD11300d |
Braavos | 0x00b05390123e1e3749ae040834342eefd541f96e210b50f4ff6de8e8dd37b08d |
https://goerli.starkgate.starknet.io/
https://faucet.goerli.starknet.io/
$ mkdir ~/.wallets
# ArgentX
$ starkli signer keystore from-key ~/.wallets/a_keystore.json
Enter private key:
Enter password:
Created new encrypted keystore file: /root/.wallets/a_keystore.json
Public key: 0x01ee7e9a91785e30a72b492cc17e2842fc6fc1ae5d25f922a174fab0bbb870e6
# Braavos
$ starkli signer keystore from-key ~/.wallets/b_keystore.json
Enter private key:
Enter password:
Created new encrypted keystore file: /root/.wallets/b_keystore.json
Public key: 0x053dba779be838414eaf38356c59b26d63846e5a0ac4d1f9e5ae6725b8c052e8
# ArgentX
$ starkli account fetch 0x05E51CAF456A394D4ED02c4e0f373d8A162851c492d382F74822b10AaD11300d --output ~/.wallets/a_account.json --rpc https://starknet-goerli.g.alchemy.com/v2/xxx
Account contract type identified as: Argent X
Description: Argent X official account
Downloaded new account config file: /root/.wallets/a_account.json
# Braavos
starkli account fetch 0x00b05390123e1e3749ae040834342eefd541f96e210b50f4ff6de8e8dd37b08d --output ~/.wallets/b_account.json --rpc https://starknet-goerli.g.alchemy.com/v2/xxx
Account contract type identified as: Braavos
Description: Braavos official proxy account
Downloaded new account config file: /root/.wallets/b_account.json
$ scarb build
Compiling cairo1_v2 v0.1.0 (/root/Ownable-Starknet/Scarb.toml)
Finished release target(s) in 1 second
.env_a
export STARKNET_RPC="https://starknet-goerli.g.alchemy.com/v2/xxx"
export STARKNET_ACCOUNT="/root/.wallets/a_account.json"
export STARKNET_KEYSTORE="/root/.wallets/a_keystore.json"
.env_b
export STARKNET_RPC="https://starknet-goerli.g.alchemy.com/v2/xxx"
export STARKNET_ACCOUNT="/root/.wallets/b_account.json"
export STARKNET_KEYSTORE="/root/.wallets/b_keystore.json"
$ starkli declare target/dev/cairo1_v2_ownable.contract_class.json --compiler-version 2.4.0
Enter keystore password:
Declaring Cairo 1 class: 0x00f6e62159da1635ccd0fe7b26a5b64d499138bb47718cdbb3dab5d5c5258e85
Compiling Sierra class to CASM with compiler version 2.4.0...
CASM class hash: 0x01cf30830a36b80f72e5a6da74186f5a9ffcee82806307c5be8316881dd4598c
Contract declaration transaction: 0x010dcf70544bdc3f97c9904da6b929ce2a12bee561c8166e008dda8ee658fc25
Class hash declared:
0x00f6e62159da1635ccd0fe7b26a5b64d499138bb47718cdbb3dab5d5c5258e85
# ArgentX
$ source .env_a
$ starkli deploy 0x00f6e62159da1635ccd0fe7b26a5b64d499138bb47718cdbb3dab5d5c5258e85 0x05E51CAF456A394D4ED02c4e0f373d8A162851c492d382F74822b10AaD11300d
Enter keystore password:
Deploying class 0x00f6e62159da1635ccd0fe7b26a5b64d499138bb47718cdbb3dab5d5c5258e85 with salt 0x04360e936156b80eba7a53295668aff3d44e977a077624c8bdd9e732159d9258...
The contract will be deployed at address 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed
Contract deployment transaction: 0x052464aa888794d3af81916244646a9af2e030ea1b6ecf4ca1f6231ac9f5856f
Contract deployed:
0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed
# Braavos
$ source .env_b
$ starkli deploy 0x00f6e62159da1635ccd0fe7b26a5b64d499138bb47718cdbb3dab5d5c5258e85 0x00b05390123e1e3749ae040834342eefd541f96e210b50f4ff6de8e8dd37b08d
Enter keystore password:
Deploying class 0x00f6e62159da1635ccd0fe7b26a5b64d499138bb47718cdbb3dab5d5c5258e85 with salt 0x05e24d42dd82fcff86e3341a6b4f944e781502e5792a15e63df468924955cebb...
The contract will be deployed at address 0x05596ddf0008770dd195d7ab22778be5362b61e1f3519f1bd7efba4fb7f2b210
Contract deployment transaction: 0x0734d968d80a92c96ca34fb27e378991461c27552ebc57b12360a386a7948e8e
Contract deployed:
0x05596ddf0008770dd195d7ab22778be5362b61e1f3519f1bd7efba4fb7f2b210
$ starkli call 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed read_owner
[
"0x05e51caf456a394d4ed02c4e0f373d8a162851c492d382f74822b10aad11300d"
]
$ starkli call 0x05596ddf0008770dd195d7ab22778be5362b61e1f3519f1bd7efba4fb7f2b210 read_owner
[
"0x00b05390123e1e3749ae040834342eefd541f96e210b50f4ff6de8e8dd37b08d"
]
$ starkli invoke 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed set_data 0x123
Enter keystore password:
Invoke transaction: 0x00af0f349edcaba005ba7ec25959fdb5282d2c474b2647a2c382dd63609c4f0b
$ starkli call 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed get_data
[
"0x0000000000000000000000000000000000000000000000000000000000000123"
]
$ starkli call 0x05596ddf0008770dd195d7ab22778be5362b61e1f3519f1bd7efba4fb7f2b210 other_func 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed
[
"0x0000000000000000000000000000000000000000000000000000000000000123"
]
$ starkli invoke 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed set_data 0x456
Enter keystore password:
Error: code=ContractError, message="Contract error"
# 转移前帐号归属
$ starkli call 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed read_owner
[
"0x05e51caf456a394d4ed02c4e0f373d8a162851c492d382f74822b10aad11300d"
]
# 转移帐号所有权
$ starkli invoke 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed transfer_ownership 0x00b05390123e1e3749ae040834342eefd541f96e210b50f4ff6de8e8dd37b08d
Enter keystore password:
Invoke transaction: 0x06035e529d6f9cd973a78334a60825c22fe8872f1492825fcb50d90bd7728405
# 转移后帐号归属
$ starkli call 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed read_owner
[
"0x00b05390123e1e3749ae040834342eefd541f96e210b50f4ff6de8e8dd37b08d"
]
$ starkli invoke 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed set_data 0x456
Enter keystore password:
Invoke transaction: 0x05d96084aa237aceab74030ce187e4ccc1d97fb7f62fc6d3c3dd447ab9aeb8f6
$ starkli call 0x05596ddf0008770dd195d7ab22778be5362b61e1f3519f1bd7efba4fb7f2b210 other_func 0x007c7ccc869c2fbbb1145b96ae1f499c493503fecf953349614030c78bd38eed
[
"0x0000000000000000000000000000000000000000000000000000000000000456"
]
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!