Esempio n. 1
0
    def upgrade_flow():
        global contract

        project = ProjectClang(input("Path to contract project: "))
        contract.bytecode = project.get_bytecode()

        user.sync_nonce(proxy)
        environment.upgrade_contract(contract,
                                     caller=user,
                                     arguments=[],
                                     gas_price=config.DEFAULT_GAS_PRICE,
                                     gas_limit=5000000,
                                     value=None,
                                     chain=config.get_chain_id(),
                                     version=config.get_tx_version())
Esempio n. 2
0
    def deploy_flow():
        global contract

        project = ProjectClang(input("Path to contract project: "))
        contract.bytecode = project.get_bytecode()

        user.sync_nonce(proxy)
        tx, address = environment.deploy_contract(
            contract=contract,
            owner=user,
            arguments=[],
            gas_price=config.DEFAULT_GAS_PRICE,
            gas_limit=5000000,
            value=None,
            chain=config.get_chain_id(),
            version=config.get_tx_version())

        logger.info("Tx hash: %s", tx)
        logger.info("Contract address (hex): %s", address.hex())
        logger.info("Contract address (bech32): %s", address.bech32())
Esempio n. 3
0
    parser.add_argument("--proxy", help="Testnet Proxy URL", required=True)
    parser.add_argument(
        "--contract",
        help="Existing contract address",
        default=
        "0000000000000000050000000000000000000000000000000000000000000000")
    parser.add_argument("--pem", help="User PEM file", required=True)
    args = parser.parse_args()

    logging.basicConfig(level=logging.DEBUG)

    # First, create a sample project called "mycounter" based on the template "simple-counter" (written in C)
    # erdpy new --template simple-counter --directory ./examples hello

    # Create a project object afterwards
    project = ProjectClang("./examples/contracts/mycounter")

    # This will build the smart contract.
    # If the buildchain is missing, it will be installed automatically.
    project.build()

    # We can inspect the bytecode like this:
    bytecode = project.get_bytecode()
    logger.info("Bytecode: %s", bytecode)

    # Now, we create a environment which intermediates deployment and execution
    environment = TestnetEnvironment(args.proxy)
    bob = Account(pem_file=args.pem)

    contract = SmartContract()
Esempio n. 4
0
    parser.add_argument("--contract", help="Existing contract address")
    parser.add_argument("--pem", help="PEM file", required=True)
    args = parser.parse_args()

    logging.basicConfig(level=logging.DEBUG)

    proxy = ElrondProxy(args.proxy)
    network = proxy.get_network_config()
    chain = network.chain_id
    gas_price = network.min_gas_price
    tx_version = network.min_tx_version

    environment = TestnetEnvironment(args.proxy)
    user = Account(pem_file=args.pem)

    project = ProjectClang(Path(__file__).parent.parent)
    bytecode = project.get_bytecode()

    # We initialize the smart contract with an actual address if IF was previously deployed,
    # so that we can start to interact with it ("query_flow")
    contract = SmartContract(address=args.contract)

    # A flow defines the desired steps to interact with the contract.
    def deploy_flow():
        global contract

        # For deploy, we initialize the smart contract with the compiled bytecode
        contract = SmartContract(bytecode=bytecode)

        tx, address = environment.deploy_contract(contract=contract,
                                                  owner=user,
Esempio n. 5
0
    parser = ArgumentParser()
    parser.add_argument("--proxy", help="Testnet Proxy URL", required=True)
    parser.add_argument(
        "--contract",
        help="Existing contract address",
        default=
        "0000000000000000050000000000000000000000000000000000000000000000")
    args = parser.parse_args()

    logging.basicConfig(level=logging.DEBUG)

    # First, create a sample project called "hello" based on the template "ultimate-answer" (written in C)
    # erdpy new --template ultimate-answer --directory ./examples hello

    # Create a project object afterwards
    project = ProjectClang("./examples/contracts/hello")

    # This will build the smart contract.
    # If the buildchain is missing, it will be installed automatically.
    project.build()

    # We can inspect the bytecode like this:
    bytecode = project.get_bytecode()
    logger.info("Bytecode: %s", bytecode)

    # Now, we create a environment which intermediates deployment and execution
    environment = TestnetEnvironment(args.proxy)
    bob = Account(pem_file="./examples/keys/bob.pem")

    # We initialize the smart contract with an actual address if IF was previously deployed,
    # so that we can start to interact with it ("query_flow")
Esempio n. 6
0
logger = logging.getLogger("examples")

if __name__ == '__main__':
    parser = ArgumentParser()
    parser.add_argument("--proxy", help="Testnet Proxy URL", required=True)
    parser.add_argument(
        "--contract",
        help="Existing contract address",
        default=
        "0000000000000000050000000000000000000000000000000000000000000000")
    parser.add_argument("--pem", help="User PEM file", required=True)
    args = parser.parse_args()

    logging.basicConfig(level=logging.DEBUG)

    project_v1 = ProjectClang("./examples/contracts/hello")
    project_v2 = ProjectClang("./examples/contracts/mycounter")

    # Now, we create a environment which intermediates deployment and execution
    environment = TestnetEnvironment(args.proxy)
    myself = Account(pem_file=args.pem)

    # We initialize the smart contract with an actual address if IF was previously deployed,
    contract = SmartContract(address=args.contract,
                             metadata=CodeMetadata(upgradeable=True))

    # A flow defines the desired steps to interact with the contract.
    def deploy_v1_flow():
        global contract
        contract.bytecode = project_v1.get_bytecode()
        tx, address = environment.deploy_contract(contract, owner=myself)