自动编译和部署以太坊 Viper 智能合约

Compile and deploy an Ethereum Viper Smart Contract automatically

有什么方法可以自动编译和部署 Viper 智能合约到一些自定义链(不是来自 ethereum.tools 的测试链)

根据GitHub issue and two posts that I found (this one and that one),最好的选择是编译合约然后手动插入geth。

任何人都可以分享他们的解决方案吗?

Github issue you provided - you can achieve it by using web3.py library and a Viper 库本身所述。
这是一个可能满足您需求的脚本示例:

from web3 import Web3, HTTPProvider
from viper import compiler
from web3.contract import ConciseContract
from time import sleep

example_contract = open('./path/to/contract.v.py', 'r')
contract_code = example_contract.read()
example_contract.close()

cmp = compiler.Compiler()
contract_bytecode = cmp.compile(contract_code).hex()
contract_abi = cmp.mk_full_signature(contract_code)

web3 = Web3(HTTPProvider('http://localhost:8545'))
web3.personal.unlockAccount('account_addr', 'account_pwd', 120)

# Instantiate and deploy contract
contract_bytecode = web3.eth.contract(contract_abi, bytecode=contract_bytecode)

# Get transaction hash from deployed contract
tx_hash = contract_bytecode.deploy(transaction={'from': 'account_addr', 'gas': 410000})

# Waiting for contract to be delpoyed
i = 0  
while i < 5:
    try:
        # Get tx receipt to get contract address
        tx_receipt = web3.eth.getTransactionReceipt(tx_hash)
        contract_address = tx_receipt['contractAddress']
        break  # if success, then exit the loop
    except:
        print("Reading failure for {} time(s)".format(i + 1))
        sleep(5+i)
        i = i + 1
        if i >= 5:
             raise Exception("Cannot wait for contract to be deployed")

# Contract instance in concise mode
contract_instance = web3.eth.contract(contract_abi, contract_address, ContractFactoryClass=ConciseContract)

# Calling contract method
print('Contract value: {}'.format(contract_instance.some_method()))