integration-testing/client/CasperClient/casper_client/casper_client.py
def deploy(self, from_addr: bytes = None, gas_limit: int = None, gas_price: int = 10, 
               payment: str = None, session: str = None, nonce: int = 0,
               public_key: str = None, private_key: str = None, args: bytes = None):
        """
        Deploy a smart contract source file to Casper on an existing running node.
        The deploy will be packaged and sent as a block to the network depending
        on the configuration of the Casper instance.

        :param from_addr:     Purse address that will be used to pay for the deployment.
        :param gas_limit:     The amount of gas to use for the transaction (unused gas
                              is refunded). Must be positive integer.
        :param gas_price:     The price of gas for this transaction in units dust/gas.
                              Must be positive integer.
        :param payment:       Path to the file with payment code.
        :param session:       Path to the file with session code.
        :param nonce:         This allows you to overwrite your own pending
                              transactions that use the same nonce.
        :param public_key:    Path to a file with public key (Ed25519)
        :param private_key:   Path to a file with private key (Ed25519)
        :param args:          List of ABI encoded arguments
        :return:              Tuple: (deserialized DeployServiceResponse object, deploy_hash)
        """

        payment = payment or session

        def hash(data: bytes) -> bytes:
            h = blake2b(digest_size=32)
            h.update(data)
            return h.digest()

        def read_binary(file_name: str):
            with open(file_name, 'rb') as f:
                return f.read()

        def read_pem_key(file_name: str):
            with open(file_name) as f:
                s = [l for l in f.readlines() if l and not l.startswith('-----')][0].strip()
                r = base64.b64decode(s) 
                return len(r) % 32 == 0 and r[:32] or r[-32:]
                

        def read_code(file_name: str, abi_encoded_args: bytes = None):
            return consensus.Deploy.Code(code = read_binary(file_name),
                                         args = abi_encoded_args)

        def sign(data: bytes):
            return (private_key
                    and consensus.Signature(sig_algorithm = 'ed25519',
                                            sig = ed25519.SigningKey(read_pem_key(private_key)).sign(data)))

        def serialize(o) -> bytes:
            return o.SerializeToString()

        # args must go to payment as well for now cause otherwise we'll get GASLIMIT error:
        # https://github.com/CasperLabs/CasperLabs/blob/dev/casper/src/main/scala/io/casperlabs/casper/util/ProtoUtil.scala#L463
        body = consensus.Deploy.Body(session = read_code(session, args),
                                     payment = read_code(payment, payment == session and args or None))

        account_public_key = public_key and read_pem_key(public_key)
        header = consensus.Deploy.Header(account_public_key = account_public_key, 
                                         nonce = nonce,
                                         timestamp = int(time.time()),
                                         gas_price = gas_price,
                                         body_hash = hash(serialize(body)))

        deploy_hash = hash(serialize(header))
        d = consensus.Deploy(deploy_hash = deploy_hash,
                             approvals = [consensus.Approval(approver_public_key = account_public_key,
                                                             signature = sign(deploy_hash))]
                                         if account_public_key
                                         else [],
                             header = header,
                             body = body)

        return self.casperService.Deploy(casper.DeployRequest(deploy = d)), deploy_hash

        Deploy a smart contract source file to Casper on an existing running node.
        The deploy will be packaged and sent as a block to the network depending
        on the configuration of the Casper instance.

        :param from_addr:     Purse address that will be used to pay for the deployment.
        :param gas_limit:     The amount of gas to use for the transaction (unused gas
                              is refunded). Must be positive integer.
        :param gas_price:     The price of gas for this transaction in units dust/gas.
                              Must be positive integer.
        :param payment:       Path to the file with payment code.
        :param session:       Path to the file with session code.
        :param nonce:         This allows you to overwrite your own pending
                              transactions that use the same nonce.
        :param public_key:    Path to a file with public key (Ed25519)
        :param private_key:   Path to a file with private key (Ed25519)
        :param args:          List of ABI encoded arguments
        :return:              Tuple: (deserialized DeployServiceResponse object, deploy_hash)
        
Deploy a smart contract source file to Casper on an existing running node.
The deploy will be packaged and sent as a block to the network depending
on the configuration of the Casper instance.
Deploy a smart contract source file to Casper on an existing running node . The deploy will be packaged and sent as a block to the network depending on the configuration of the Casper instance .
def deploy(self, from_addr: bytes = None, gas_limit: int = None, gas_price: int = 10, 
               payment: str = None, session: str = None, nonce: int = 0,
               public_key: str = None, private_key: str = None, args: bytes = None):
        payment = payment or session
        def hash(data: bytes) -> bytes:
            h = blake2b(digest_size=32)
            h.update(data)
            return h.digest()
        def read_binary(file_name: str):
            with open(file_name, 'rb') as f:
                return f.read()
        def read_pem_key(file_name: str):
            with open(file_name) as f:
                s = [l for l in f.readlines() if l and not l.startswith('-----')][0].strip()
                r = base64.b64decode(s) 
                return len(r) % 32 == 0 and r[:32] or r[-32:]
        def read_code(file_name: str, abi_encoded_args: bytes = None):
            return consensus.Deploy.Code(code = read_binary(file_name),
                                         args = abi_encoded_args)
        def sign(data: bytes):
            return (private_key
                    and consensus.Signature(sig_algorithm = 'ed25519',
                                            sig = ed25519.SigningKey(read_pem_key(private_key)).sign(data)))
        def serialize(o) -> bytes:
            return o.SerializeToString()
        body = consensus.Deploy.Body(session = read_code(session, args),
                                     payment = read_code(payment, payment == session and args or None))
        account_public_key = public_key and read_pem_key(public_key)
        header = consensus.Deploy.Header(account_public_key = account_public_key, 
                                         nonce = nonce,
                                         timestamp = int(time.time()),
                                         gas_price = gas_price,
                                         body_hash = hash(serialize(body)))
        deploy_hash = hash(serialize(header))
        d = consensus.Deploy(deploy_hash = deploy_hash,
                             approvals = [consensus.Approval(approver_public_key = account_public_key,
                                                             signature = sign(deploy_hash))]
                                         if account_public_key
                                         else [],
                             header = header,
                             body = body)
        return self.casperService.Deploy(casper.DeployRequest(deploy = d)), deploy_hash
def deploy ( self , from_addr : bytes = None , gas_limit : int = None , gas_price : int = 10 , payment : str = None , session : str = None , nonce : int = 0 , public_key : str = None , private_key : str = None , args : bytes = None ) : payment = payment or session def hash ( data : bytes ) -> bytes : h = blake2b ( digest_size = 32 ) h . update ( data ) return h . digest ( ) def read_binary ( file_name : str ) : with open ( file_name , 'rb' ) as f : return f . read ( ) def read_pem_key ( file_name : str ) : with open ( file_name ) as f : s = [ l for l in f . readlines ( ) if l and not l . startswith ( '-----' ) ] [ 0 ] . strip ( ) r = base64 . b64decode ( s ) return len ( r ) % 32 == 0 and r [ : 32 ] or r [ - 32 : ] def read_code ( file_name : str , abi_encoded_args : bytes = None ) : return consensus . Deploy . Code ( code = read_binary ( file_name ) , args = abi_encoded_args ) def sign ( data : bytes ) : return ( private_key and consensus . Signature ( sig_algorithm = 'ed25519' , sig = ed25519 . SigningKey ( read_pem_key ( private_key ) ) . sign ( data ) ) ) def serialize ( o ) -> bytes : return o . SerializeToString ( ) body = consensus . Deploy . Body ( session = read_code ( session , args ) , payment = read_code ( payment , payment == session and args or None ) ) account_public_key = public_key and read_pem_key ( public_key ) header = consensus . Deploy . Header ( account_public_key = account_public_key , nonce = nonce , timestamp = int ( time . time ( ) ) , gas_price = gas_price , body_hash = hash ( serialize ( body ) ) ) deploy_hash = hash ( serialize ( header ) ) d = consensus . Deploy ( deploy_hash = deploy_hash , approvals = [ consensus . Approval ( approver_public_key = account_public_key , signature = sign ( deploy_hash ) ) ] if account_public_key else [ ] , header = header , body = body ) return self . casperService . Deploy ( casper . DeployRequest ( deploy = d ) ) , deploy_hash
Deploy a smart contract source file to Casper on an existing running node.
Deploy a smart contract source file to Casper on an existing running node .
"""
        Deploy a smart contract source file to Casper on an existing running node.
        The deploy will be packaged and sent as a block to the network depending
        on the configuration of the Casper instance.

        :param from_addr:     Purse address that will be used to pay for the deployment.
        :param gas_limit:     The amount of gas to use for the transaction (unused gas
                              is refunded). Must be positive integer.
        :param gas_price:     The price of gas for this transaction in units dust/gas.
                              Must be positive integer.
        :param payment:       Path to the file with payment code.
        :param session:       Path to the file with session code.
        :param nonce:         This allows you to overwrite your own pending
                              transactions that use the same nonce.
        :param public_key:    Path to a file with public key (Ed25519)
        :param private_key:   Path to a file with private key (Ed25519)
        :param args:          List of ABI encoded arguments
        :return:              Tuple: (deserialized DeployServiceResponse object, deploy_hash)
        """ # args must go to payment as well for now cause otherwise we'll get GASLIMIT error: # https://github.com/CasperLabs/CasperLabs/blob/dev/casper/src/main/scala/io/casperlabs/casper/util/ProtoUtil.scala#L463
(deserialized DeployServiceResponse object, deploy_hash)
( deserialized DeployServiceResponse object deploy_hash )
self
from_addr
bytes
Purse address that will be used to pay for the deployment.
Purse address that will be used to pay for the deployment .
gas_limit
int
The amount of gas to use for the transaction (unused gas
is refunded). Must be positive integer.
The amount of gas to use for the transaction ( unused gas is refunded ) . Must be positive integer .
gas_price
int
The price of gas for this transaction in units dust/gas.
Must be positive integer.
The price of gas for this transaction in units dust / gas . Must be positive integer .
payment
str
Path to the file with payment code.
Path to the file with payment code .
session
str
Path to the file with session code.
Path to the file with session code .
nonce
int
This allows you to overwrite your own pending
transactions that use the same nonce.
This allows you to overwrite your own pending transactions that use the same nonce .
public_key
str
Path to a file with public key (Ed25519)
Path to a file with public key ( Ed25519 )
private_key
str
Path to a file with private key (Ed25519)
Path to a file with private key ( Ed25519 )
args
bytes
List of ABI encoded arguments
List of ABI encoded arguments