freeton_wallet icon indicating copy to clipboard operation
freeton_wallet copied to clipboard

Failing to deploy a contract when providing --pubkey option

Open arozovyk opened this issue 2 years ago • 0 comments

Having 2 contracts that require each others addresses in constructor, as in https://github.com/tonlabs/samples/blob/master/solidity/19_CasinoOwner.sol https://github.com/tonlabs/samples/blob/master/solidity/19_Casino.sol

leeds us to precalculating the address of one of the contracts in order to be able to deploy the other. Steps to replicate :

ft contract build 19_CasinoOwner.sol 
ft contract build 19_Casino.sol 
ft client -- genphrase
ft client -- getkeypair key19.json "rule script joy unveil chaos replace fox recipe hedgehog heavy surge online"
#calculate the address with 
ft client -- genaddr --setkey key19.json  ~/.ft/contracts/19_CasinoOwner/1.tvc ~/.ft/contracts/19_CasinoOwner/1.abi.json
#let's say it gives Raw address : 0:413cc0382fcae0ad3fd93fce61f528d85d34be7c14fc95589c85eebc51aece80
#then deploy the Casino providing the precalculated Casino Owener address with
ft contract deploy 19_Casino --create casino '{"casinoAssurance":10000000,"minimalBet":420,"ownerWallet":"0:413cc0382fcae0ad3fd93fce61f528d85d34be7c14fc95589c85eebc51aece80"}' -f
cat key19.key 
#gives us the pubkey - 178af238c608580c8f5dfc05467ad35b0b8df6b3f2ec621d2b1971aec460a830 
#so we deploy the Casino Owner with 
ft contract deploy 19_CasinoOwner --create casinoowner '{"casino":"0:6107d8e4c75bec72c9888d46844f1717b387ed166d238e7f1085b432ce881028"}' --pubkey=178af238c608580c8f5dfc05467ad35b0b8df6b3f2ec621d2b1971aec460a830 -f

Fails with follwing error, (because a new phrase/key are generated regardless of the fact that --pubkey option is provided ?)

ft contract deploy 19_CasinoOwner --create casinoowner '{"casino":"0:6107d8e4c75bec72c9888d46844f1717b387ed166d238e7f1085b432ce881028"}' --pubkey=178af238c608580c8f5dfc05467ad35b0b8df6b3f2ec621d2b1971aec460a830 -f
Config loaded from /Users/artemiyrozovyk/.ft/config.json
Network: sandbox1
Loading wallet file /Users/artemiyrozovyk/.ft/sandbox1/wallet.json
Generating new key "casinoowner"
Passphrase: "kiss report disease develop disagree motion always mouse dose bread floor upper"
{ "public": "bd1a16c1a3f2bcc7adde5c9cbafb3641675ae11b6e25a21fe6ec4f13ae3d378b",
  "secret": "16362bf9034a6f743692410a7e8ffcafec9e467a6c7d843a922b9b314fdb933d" }
Key for user "casinoowner" generated
Account "casinoowner" modified.
{
  "name": "casinoowner",
  "passphrase": "kiss report disease develop disagree motion always mouse dose bread floor upper",
  "pair": {
    "public": "bd1a16c1a3f2bcc7adde5c9cbafb3641675ae11b6e25a21fe6ec4f13ae3d378b",
    "secret": "16362bf9034a6f743692410a7e8ffcafec9e467a6c7d843a922b9b314fdb933d"
  },
  "account": {
    "address": "0:67bbe8e45027e5275dac638d7f19495f9bf59cfdd1c136dae4a68bef62c03311",
    "contract": "19_CasinoOwner/1"
  }
}
Sending 1 TON from deployer "user1"
call: 0:f89872394a383dc289f27ded48f02a6269e19d02be5821ba8081c67a1070588a
method: submitTransaction
params: {"dest":"0:67bbe8e45027e5275dac638d7f19495f9bf59cfdd1c136dae4a68bef62c03311","value":1000000000,"bounce":false,"allBalance":false,"payload":""}
signed: user1
MessageId: 356908bf482a8e7e853ff56bfa1291e2b3707a73d0aa6687930f35fae4026a48
call result:
{
  "transId": "0"
}
Saving wallet file /Users/artemiyrozovyk/.ft/sandbox1/wallet.json
Saving config file /Users/artemiyrozovyk/.ft/config.json
Deploying contract "19_CasinoOwner/1" to casinoowner
node url: http://0.0.0.0:7081
fatal exception Deploy failed: {
    code:409.000000
    message:Account does not exist. You need to transfer funds to this account first to have a positive balance and then deploy its code.
Possible reason: Account does not exist. You need to transfer funds to this account first to have a positive balance and then deploy its code
    data:{
      core_version:1.24.0
      account_address:0:413cc0382fcae0ad3fd93fce61f528d85d34be7c14fc95589c85eebc51aece80
      exit_arg:null
      contract_error:null
      config_servers:[
        0:http://0.0.0.0:7081
      ]
      query_url:http://0.0.0.0:7081/graphql
      query_ip_address:127.0.0.1:7081
      transaction_id:9cd94bb5fe36bc196104669fbd23658ced747feb507c8096c012d92e6a0f6687
    }
  }

arozovyk avatar Nov 22 '21 12:11 arozovyk