Go module for the Cardano Blockchain

cardano-go

cardano-go is both a library for creating go applicactions that interact with the Cardano Blockchain as well as a CLI to manage Cardano Wallets.

Installation from source

Clone the repository using git clone

$ git clone https://github.com/echovl/cardano-wallet.git

Compile the source code and install the executable

$ make && sudo make install

Dependencies

For balance and transfer commands cardano-node and cardano-cli are required. You can install them using this guide https://docs.cardano.org/projects/cardano-node/en/latest/getting-started/install.html

Getting started

First create a new wallet and generate your mnemonic squence:

$ cardano-wallet new-wallet myWallet -p simplePassword
mnemonic: banner capital gift plate worth sand pass canvas pave decade pig borrow cruel lunar arena

If you already have a wallet you can restore it using a mnemonic and password:running this command:

$ cardano-wallet new-wallet restoredWallet -m=talent,risk,require,split,leave,script,panel,slight,entire,soap,chase,pill,grant,laugh,fringe -p simplePassword

You can inspect your wallets using the list-wallets command:

$ cardano-wallet list-wallets
ID              NAME      ADDRESS
wl_uu4FmZvNYG   myWallet  1

By default a new wallet is created with one payment address, you can create more addresses running the following command:

$ cardano-wallet new-address wl_uu4FmZvNYG
New address addr_test1vz8vyz6pk6hwgwqz239rcyk52e659aefa8g08amm80tq8ag9eng6q

To get all addresses run:

$ cardano-wallet list-address wallet_WGejugqca4 --testnet
PATH                      ADDRESS
m/1852'/1815'/0'/0/0      addr_test1vpfla0wgltpjwxzt52p7wkn720eact33udlq9z8xrc6cypc3c70f5

You can get your balance running:

$ cardano-wallet balance wallet_WGejugqca4 --testnet
ASSET                     AMOUNT
Lovelace                  1000000000
Owner
Alonso Villegas
Always learning
Alonso Villegas
Comments
  • Avoid building transaction in AddChangeIfNeeded of TxBuilder

    Avoid building transaction in AddChangeIfNeeded of TxBuilder

    The AddChangeIfNeeded of TxBuilder calls tx.build() inside which does a transaction signing. Calling tx.Build() at this stage is an awkward way of verifying transaction, especially when the build function mostly does transaction signing.

    Note that after AddChangeIfNeeded is called, we still need to build the transaction again and therefore do the signing twice. In general, we should only do transaction signing once when all data is available.

    Can we remove tx.build() in AddChangeIfNeeded ?

  • Incorrect min amount for multiasset transaction

    Incorrect min amount for multiasset transaction

    I think this min value calculation for multiasset transaction is incorrect:

    func (tb *TxBuilder) MinCoinsForTxOut(txOut *TxOutput) Coin {
    	var size uint
    	if txOut.Amount.OnlyCoin() {
    		size = 1
    	} else {
    		numAssets := txOut.Amount.MultiAsset.numAssets()
    		assetsLength := txOut.Amount.MultiAsset.assetsLength()
    		numPIDs := txOut.Amount.MultiAsset.numPIDs()
    
    		size = 6 + uint(math.Floor(
    			float64(numAssets*12+assetsLength+numPIDs*28+7)/8,
    		))
    	}
    	return Coin(utxoEntrySizeWithoutVal+size) * tb.protocol.CoinsPerUTXOWord
    }
    
    

    I have a multi-asset input and my values are as follow:

    numAssets = 1, assetsLength = 8, numPIDs = 1, utxoEntrySizeWithoutVal = 27, tb.protocol.CoinsPerUTXOWord
     = 4310
    

    Total coin amount = 168090 (or 0.16809 ADA)

    This number is clearly smaller than min 1.3 ADA required to transfer multiasset. I got BabbageOutputTooSmallUTxO error when submitting this. Please check this function again for multi-asset

  • Improve delegation tx management

    Improve delegation tx management

    This closes #37 This closes #38

    This will add some minimal (opinionated) helper functions regarding bech32 (also exposing these) and stake address management. The core of this proposal is the tx builder improvement to be able to set in advance a number of expected witness aiming for the correct fee calculation, allowing us to build a tx that is partially signed.

    In my case I am using it to build a tx that include a stake delegation cert, and the only "payment" input is owned by someone that is not the owner of the stake key. In this way I prepare in the backend the tx (paying the delegation tx fee) and propose the 3rd part to sign the tx w/o spending nothing.

    I guess the code is more clear that my explanation.

  • Deserialize not working for Amount.Inputs

    Deserialize not working for Amount.Inputs

    This unit test is setting transaction body inputs to empty https://github.com/echovl/cardano-go/blob/fd832fe8c7114cf9ea81b549b562bdfaab50aeb8/tx_test.go#L84? Any problem with serializing/deserializing for the map in cbor?

  • PrvKey not generating the same signature as PyCardano

    PrvKey not generating the same signature as PyCardano

    Hello,

    We are trying to sign transactions using the library and we came across an issue with signatures:

    Given the following private key (only has 5 testnet ADA):

    bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e8

    Using the following procedure, we try to sign the hash of the transaction:

      var psk crypto.PrvKey
      var ssk crypto.PrvKey
    
      psk, _ = hex.DecodeString(paymentSkey[4:])
      ssk, _ = hex.DecodeString(stakeSkey[4:])
    
      var tx cardano.Tx
    
      bytes, err := hex.DecodeString(transactionCBOR)
    
      if err != nil {
        log.Fatal(err)
      }
    
      cbor.Unmarshal(bytes, tx)
    
      txHash, err := tx.Hash()
    
      fmt.Println("SKEY: ", paymentSkey[4:])
      fmt.Println("TXHASH: ", hex.EncodeToString(txHash))
      fmt.Println("PUBKEY: ", hex.EncodeToString(psk.PubKey()))
    

    This results in:

    SKEY:  bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e8
    TXHASH:  0f1b6d09c85eaec039f086c96c5dfc05adc4ca413e2886bd08e72a8c2cafc03f
    PUBKEY:  18be1cd172326473a80b085008101b999d85f1f3610f297cd36268ee064d6082
    PKH:  8afcd22c9c898f6c1e244419ba52f4b1ed91c1cfbbcfff6eaf1a769c
    
    a1008282582018be1cd172326473a80b085008101b999d85f1f3610f297cd36268ee064d608258405c30ce7ceb5f358cae1055aaaf0d09cec17ec8c39bdf2e23f05f1b405dc3cb71df263408038f8546b5b33d4c2c22046e6ffd594c6edb094c67bfcfc0c0a8310f825820baa5f44a3de96cf55d0cfa0b6a2ad4df94b37d88fa9dbad0111af2cc68cd31f15840fcb1ba2be3778f1bf5410dfa95a3a9b5221a245646146fc6d35931d24ba0efb33cd6426142cd8784e8aa856da44b603ea74ff0e9dc3002085645807313a2b30c
    

    Transaction signing is not working for me right now using that.

    However, another library pycardano produces the following:

    Python 3.9.13 (main, May 24 2022, 21:13:51) 
    [Clang 13.1.6 (clang-1316.0.21.2)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from pycardano import *
    >>> psk = PaymentSigningKey.from_cbor("5820bc4070aa2ac9883c1f61a46e8f9e06bb7a432211f3689125c3d6e8c136b270e8") # 5820 prefix is just CBOR for 'bytes'
    >>> psk.to_verification_key().to_primitive().hex()
    '448601922876ffa826afebc1dbd2cc1affa4fd6efc65056f9db6dfb958fe1803'
    >>> tx_hash = b'0f1b6d09c85eaec039f086c96c5dfc05adc4ca413e2886bd08e72a8c2cafc03f'
    >>> psk.sign(tx_hash).hex()
    'dd9276eb0f51ec1f3a2c0d764b797ef8423b376e8ee43ac8016c9de6613cde61692d16d38589b8e62471e015f13df1c362c3a369a41719ea1aca43342e2c9601'
    >>> 
    

    What am I missing?

  • is this support 12-word mnemonic?

    is this support 12-word mnemonic?

    it seems generate not the same as the bussiness Haskell one ,if the mnemonic is 12 words

    the payment address its not the same with https://github.com/input-output-hk/cardano-addresses generate , which use the same mnemonic

  • Fix MultiAsset Stringer in primitive.go

    Fix MultiAsset Stringer in primitive.go

    We can't just ignore the policy id here. When two assets with different policies have the same name (eg default values like "Asset 1" or empty, this overwrites previously set values and returns wrong results)

  • Add support for preprod testnet

    Add support for preprod testnet

    This repo currently only supports old testnet. We need to add support for preprod.

    I can create a PR for this repo as I already has the PR in my forked version

  • how to set socket path in cardano wallet ?

    how to set socket path in cardano wallet ?

    hey every one i charge my testnet address that generated by this package wallet but when i call balance method i get 0 . i guess that it's because of socket path that not set in variable 'CARDANO_NODE_SOCKET_PATH'

    how we should do that ?

  • Add Preprod support

    Add Preprod support

    This PR add new network type preprod for testnet. The blockfrost API server does not have preprod type yet, so we have to hardcode the blockfrost API URL for preprod.

    This could be extended to support Testnet Preview

    Close https://github.com/echovl/cardano-go/issues/35

    @echovl

  • #31 Incorrect min amount

    #31 Incorrect min amount

    Fixes #31

    Two points aren't fixed:

    I suggest to close this issue and open another one as feature.

  • Add support for StakeAddress and BaseAddress output

    Add support for StakeAddress and BaseAddress output

    This PR includes:

    • Deprecate Wallet.Addresses() and replace it with Wallet.EnterpriseAddresses()
    • Deprecate Wallet.Keys() and replace it with Wallet.PrvKeys()
    • New Wallet.BaseAddresses()
    • StakeAddress support for Address and Wallet
    • Add PoolCost in poolRegistration struct

    closes #45 closes #20

  • Add support for partially signed tx, closes #38

    Add support for partially signed tx, closes #38

    • allow to set additional witnesses for partially signed tx preparation
    • change calculateMinFee to consider additional witnesses that will increase the tx length. It is still not clear how to precisely calculate the bytes for witnesses, in this implementation for each additional witnesses there will be an additional 100 bytes, (32 public key, 64 signature, 4 index/key in cbor). Those are not actually enough so we are considering 1 additional byte for each additional witness after the first.
  • Add support for building partially signed transaction (especially delegation ones)

    Add support for building partially signed transaction (especially delegation ones)

    I would like to be able to create a transaction that include delegation certificate for a 3rd party (the stake key owner) that will sign the tx lately. To do so the address package should be improved to facilitate the management of stake addresses (aka reward addresses), and allow the tx builder to know that the transaction will be signed by a well known number of witnesses in advance, to be able to calculate fees correctly.

  • Expose some utilities functions from the bech32 internal package

    Expose some utilities functions from the bech32 internal package

    Would be good to have some basic functions exposed as package that can be imported from other project, including the CIP-5 prefixes. This could be useful to eventually implement some basic "marshaling machinery" in project that are using cardano-go.

Blockchain-go - A repository that houses a blockchain implemented in Go

blockchain-go This is a repository that houses a blockchain implemented in Go. F

May 1, 2022
DERO Homomorphic Encryption Blockchain Protocol
DERO Homomorphic Encryption Blockchain Protocol

Homomorphic encryption is a form of encryption allowing one to perform calculations on encrypted data without decrypting it first. The result of the computation is in an encrypted form, when decrypted the output is the same as if the operations had been performed on the unencrypted data.

Dec 27, 2022
A simplified blockchain implementation in Golang

A simplified blockchain implementation in Golang

Dec 31, 2022
DERO: Secure, Anonymous Blockchain with Smart Contracts. Subscribe to Dero announcements by sending mail to [email protected] with subject: subscribe announcements
DERO: Secure, Anonymous Blockchain with Smart Contracts.  Subscribe to Dero announcements by sending mail to lists@dero.io with subject: subscribe announcements

Welcome to the Dero Project DERO News Forum Wiki Explorer Source Twitter Discord Github Stats WebWallet Medium Table of Contents ABOUT DERO PROJECT DE

Dec 7, 2022
run ABI encoded data against the ethereum blockchain

Run EVM code against a database at a certain block height - Note You can't run this against a running geth node - because that would share the db and

Nov 11, 2021
chia-blockchain some function implement in golang

gochia chia-blockchain some function implement in golang Package bls-signatures implement blspy Usage? Now we can use it to generate plot memo and id,

May 27, 2022
Frontier Chain is a blockchain application built using Cosmos SDK and Tendermint.

Frontier Chain Frontier Chain is a blockchain application built using Cosmos SDK and Tendermint. Setup Initialize the blockchain with one validator no

Jul 12, 2022
Implementing blockchain using Golang ✔️
 Implementing blockchain using Golang ✔️

Implementing blockchain using Golang ✔️ Keys The Blockchain uses ECDSA (224 bits) keys.

May 24, 2022
Gochain is a Blockchain written in go
Gochain is a Blockchain written in go

gochain gochain is a proof-of-work blockchain written in go. Features Proof-Of-Work Persistence CLI Transactions Addresses Merkle Tree Network How to

Jul 14, 2022
LINE Financial Blockchain forked from gaia

LFB(LINE Financial Blockchain) This repository hosts LFB(LINE Financial Blockchain). This repository is forked from gaia at 2021-03-15. LFB is a mainn

Dec 21, 2022
utreexo blockchain skeleton
utreexo blockchain skeleton

sunyata sunyata is a blockchain skeleton. It implements a minimally-functional proof-of-work blockchain, including consensus algorithms, p2p networkin

May 24, 2022
OmniFlix Hub is a blockchain built using Cosmos SDK and Tendermint and created with Starport.

OmniFlix Hub is the root chain of the OmniFlix Network. Sovereign chains and DAOs connect to the OmniFlix Hub to manage their web2 & web3 media operations (mint, manage, distribute & monetize) as well as community interactions.

Nov 10, 2022
A plugin that turn hashicorp vault into blockchain wallet.
A plugin that turn hashicorp vault into blockchain wallet.

dq-vault - Hashicorp vault BTC/ETH plugin This vault plugin stores a user's mnemonic inside vault in an encrypted manner. The plugin uses this stored

Dec 7, 2022
Yu is a highly customizable blockchain framework.
Yu is a highly customizable blockchain framework.

禹 Yu is a highly customizable blockchain framework. 中文文档 Overall Structure Introduction By using Yu, you can customize three levels to develop your ow

Jan 7, 2023
Use golang to reproduce the basic blockchain

Blockchain_with_Go Use golang to reproduce the basic blockchain Update Panel V0.1 No transactions but noly blocks are allowed. V0.5 Transactions are n

Dec 30, 2022
Yu is a highly customizable blockchain framework.
Yu is a highly customizable blockchain framework.

禹 Yu is a highly customizable blockchain framework. 中文文档 Overall Structure Introduction By using Yu, you can customize three levels to develop your ow

Dec 11, 2022
Evmos is a scalable, high-throughput Proof-of-Stake blockchain that is fully compatible and interoperable with Ethereum.

Evmos Evmos is a scalable, high-throughput Proof-of-Stake blockchain that is fully compatible and interoperable with Ethereum. It's built using the Co

Dec 31, 2022
Source for the Chillis & Associates blockchain nodes

Chillis & Associates chillisd Repository This repository contains the source code for validators on the Chillis network. The source is based on the wa

Feb 8, 2022
A blockcypher exporter to monitor your blockchain nodes to Prometheus.

A blockcypher exporter to monitor your blockchain nodes to Prometheus. Metrics are retrieved using the BlockCypher REST API.

Nov 2, 2021