.container { width:100% !important; }" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from IPython.core.display import display, HTML\n", "display(HTML(\"\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set Up Environment" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "connections = {\n", "\"mainnet\": {\"iconservice\": \"https://ctz.solidwallet.io\", \"nid\": 1},\n", "\"yeouido\": {\"iconservice\": \"https://bicon.net.solidwallet.io\", \"nid\": 3},\n", "\"euljiro\": {\"iconservice\": \"https://test-ctz.soli"> .container { width:100% !important; }" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from IPython.core.display import display, HTML\n", "display(HTML(\"\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set Up Environment" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "connections = {\n", "\"mainnet\": {\"iconservice\": \"https://ctz.solidwallet.io\", \"nid\": 1},\n", "\"yeouido\": {\"iconservice\": \"https://bicon.net.solidwallet.io\", \"nid\": 3},\n", "\"euljiro\": {\"iconservice\": \"https://test-ctz.soli"> .container { width:100% !important; }" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from IPython.core.display import display, HTML\n", "display(HTML(\"\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Set Up Environment" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "connections = {\n", "\"mainnet\": {\"iconservice\": \"https://ctz.solidwallet.io\", \"nid\": 1},\n", "\"yeouido\": {\"iconservice\": \"https://bicon.net.solidwallet.io\", \"nid\": 3},\n", "\"euljiro\": {\"iconservice\": \"https://test-ctz.soli">
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>.container { width:100% !important; }</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from IPython.core.display import display, HTML\\n",
    "display(HTML(\\"<style>.container { width:100% !important; }</style>\\"))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set Up Environment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "connections = {\\n",
    "\\"mainnet\\": {\\"iconservice\\": \\"<https://ctz.solidwallet.io>\\",       \\"nid\\": 1},\\n",
    "\\"yeouido\\": {\\"iconservice\\": \\"<https://bicon.net.solidwallet.io>\\", \\"nid\\": 3},\\n",
    "\\"euljiro\\": {\\"iconservice\\": \\"<https://test-ctz.solidwallet.io>\\",  \\"nid\\": 2},\\n",
    "\\"pagoda\\":  {\\"iconservice\\": \\"<https://zicon.net.solidwallet.io>\\", \\"nid\\":80},\\n",
    "\\"custom\\":  {\\"iconservice\\": \\"<http://13.57.193.25:9000/\\>",        \\"nid\\": 3}}\\n",
    "\\n",
    "env = connections[\\"custom\\"] # mainnet, yeouido, euljiro, pagoda, custom"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from iconsdk.exception import JSONRPCException\\n",
    "from iconsdk.libs.in_memory_zip import gen_deploy_data_content\\n",
    "from iconsdk.icon_service import IconService\\n",
    "from iconsdk.providers.http_provider import HTTPProvider\\n",
    "from iconsdk.builder.transaction_builder import CallTransactionBuilder, TransactionBuilder, DeployTransactionBuilder\\n",
    "from iconsdk.builder.call_builder import CallBuilder\\n",
    "from iconsdk.signed_transaction import SignedTransaction\\n",
    "from iconsdk.wallet.wallet import KeyWallet\\n",
    "from iconsdk.utils.convert_type import convert_hex_str_to_int\\n",
    "from repeater import retry\\n",
    "import json\\n",
    "import os\\n",
    "\\n",
    "ICX = 1000000000000000000 # 10**18\\n",
    "GOVERNANCE_ADDRESS = \\"cx0000000000000000000000000000000000000000\\"\\n",
    "\\n",
    "contracts = {'dex':  {'zip': 'core_contracts/dex.zip',   'SCORE': 'cx7915f8111043cb6a8f42a528af16de0fe0690834'},\\n",
    "             'sicx': {'zip': 'token_contracts/sicx.zip', 'SCORE': 'cxced84c6b7d71465a9b99396137df2d7da233a6a3'},\\n",
    "             'icd':  {'zip': 'token_contracts/icd.zip',  'SCORE': 'cx9e7d7d88de153f7ae3117472f278169475674b09'},\\n",
    "             'bal':  {'zip': 'token_contracts/bal.zip',  'SCORE': 'cx7ddc34e80e6e96f66f67255fa8f3b87e6b7a648a'}}\\n",
    "\\n",
    "@retry(JSONRPCException, tries=10, delay=1, back_off=2)\\n",
    "def get_tx_result(_tx_hash):\\n",
    "    tx_result = icon_service.get_transaction_result(_tx_hash)\\n",
    "    return tx_result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "icon_service = IconService(HTTPProvider(env[\\"iconservice\\"], 3))\\n",
    "NID = env[\\"nid\\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "wallet = KeyWallet.load(\\"keystores/keystore_test1.json\\", \\"test1_Account\\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Raised JSONRPCException while returning the custom response. Error message: {'code': -32602, 'message': 'Pending transaction'}\\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'code': -32602, 'message': 'Pending transaction'} (Json rpc error), Retrying in 1 seconds...\\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Raised JSONRPCException while returning the custom response. Error message: {'code': -32602, 'message': 'Pending transaction'}\\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'code': -32602, 'message': 'Pending transaction'} (Json rpc error), Retrying in 1 seconds...\\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Raised JSONRPCException while returning the custom response. Error message: {'code': -32602, 'message': 'Pending transaction'}\\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'code': -32602, 'message': 'Pending transaction'} (Json rpc error), Retrying in 2 seconds...\\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Raised JSONRPCException while returning the custom response. Error message: {'code': -32602, 'message': 'Pending transaction'}\\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'code': -32602, 'message': 'Pending transaction'} (Json rpc error), Retrying in 1 seconds...\\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Raised JSONRPCException while returning the custom response. Error message: {'code': -32602, 'message': 'Pending transaction'}\\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'code': -32602, 'message': 'Pending transaction'} (Json rpc error), Retrying in 1 seconds...\\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'dex': {'zip': 'core_contracts/dex.zip',\\n",
       "  'SCORE': 'cx7915f8111043cb6a8f42a528af16de0fe0690834'},\\n",
       " 'sicx': {'zip': 'token_contracts/sicx.zip',\\n",
       "  'SCORE': 'cxced84c6b7d71465a9b99396137df2d7da233a6a3'},\\n",
       " 'icd': {'zip': 'token_contracts/icd.zip',\\n",
       "  'SCORE': 'cx9e7d7d88de153f7ae3117472f278169475674b09'},\\n",
       " 'bal': {'zip': 'token_contracts/bal.zip',\\n",
       "  'SCORE': 'cx7ddc34e80e6e96f66f67255fa8f3b87e6b7a648a'}}"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "step_limit = 4000100000\\n",
    "\\n",
    "for score, loc in contracts.items():\\n",
    "    deploy_transaction = DeployTransactionBuilder()\\\\\\n",
    "        .from_(wallet.get_address())\\\\\\n",
    "        .to(GOVERNANCE_ADDRESS)\\\\\\n",
    "        .nid(NID)\\\\\\n",
    "        .nonce(100)\\\\\\n",
    "        .content_type(\\"application/zip\\")\\\\\\n",
    "        .content(gen_deploy_data_content(loc[\\"zip\\"]))\\\\\\n",
    "        .build()\\n",
    "\\n",
    "    signed_transaction = SignedTransaction(deploy_transaction, wallet, step_limit)\\n",
    "    tx_hash = icon_service.send_transaction(signed_transaction)\\n",
    "\\n",
    "    res = get_tx_result(tx_hash)\\n",
    "    contracts[score][\\"SCORE\\"] = res['scoreAddress']\\n",
    "contracts"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}