Unable to make Mint_Transaction from Client

Hello, I’m having some issues trying to make a Mint Transaction.
Actually I’m developing a Net Core Client, I can make queries and transactions between existing accounts, but I’m not sure how to make the Mint_Transaction, since the SourceAccount doesn’t exist.

private static Types.RawTransaction CreateMintRawTx(string senderHex, UInt64 seqNum, UInt64 amount, UInt64 maxGasAmount, UInt64 maxGasUnitPrice, UInt64 expirationTime)
    {
        HexEncoder hex = new HexEncoder();

        Types.RawTransaction rawTx = new Types.RawTransaction();
        rawTx.SenderAccount = ByteString.CopyFrom(hex.DecodeData(senderHex));
        rawTx.SequenceNumber = seqNum;
        rawTx.Program = new Types.Program();
        rawTx.Program.Code = Google.Protobuf.ByteString.CopyFrom(Convert.FromBase64String("TElCUkFWTQoBAAcBSgAAAAYAAAADUAAAAAYAAAAMVgAAAAUAAAANWwAAAAQAAAAFXwAAADMAAAAEkgAAACAAAAAHsgAAAA0AAAAAAAABAAIAAwABBAACAAIEAgMCBAIGPFNFTEY+DExpYnJhQWNjb3VudAlMaWJyYUNvaW4EbWFpbg9taW50X3RvX2FkZHJlc3MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAgAEAAwADAERAQI="));

        var senderArg = new Types.TransactionArgument { Type = Types.TransactionArgument.Types.ArgType.Address };
        senderArg.Data = Google.Protobuf.ByteString.CopyFrom(hex.DecodeData(senderHex));
        rawTx.Program.Arguments.Add(senderArg);

        var amountArg = new Types.TransactionArgument { Type = Types.TransactionArgument.Types.ArgType.U64 };
        amountArg.Data = Google.Protobuf.ByteString.CopyFrom(BitConverter.GetBytes(amount));
        rawTx.Program.Arguments.Add(amountArg);

        rawTx.MaxGasAmount = maxGasAmount;
        rawTx.GasUnitPrice = maxGasUnitPrice;
        rawTx.ExpirationTime = expirationTime;

        return rawTx;


    }

and this is that it respond: “SendingAccountDoesNotExist”

Reviewing the Experimental Testnet Explorer, it seems that when is a Mint_Transaction the source account its the “0000000000000000000000000000000000000000000000000000000000000000”

Probably I should use that to create the RAWTX, but I can’t sign it, or I dont know how to do it.

The main question in this are:

  • How can I sign a Mint_Transaction since the SourceAccount is the “00…00”
  • Is there another way to send the Mint_Transaction program that differs of the Peer_To_Peer_Transaction?

Thanks in advance.

Diego.-

1 Like

Are you attempting to mint on testnet or on a local libra swarm? If you’re trying to mint on testnet, we use a faucet service which will generate and sign the transaction for you. Please take a look at client/src/client_proxy.rs::mint_coins_with_faucet_service() to see how this is being done.

If you wish to mint coins on a local libra swarm, you’ll need to mint with the local faucet account that is created when you launch the swarm

I’m trying to mint on the testnet, I saw that code. But I’m not sure how to connect my client to the faucet service.

  • Is that exposed anywhere? or is part of the libra testnet?
  • Is submitted through the AdmissionControl (SubmitTransaction) or is there other method?

Thanks for your anwser!, I will look for how to do it using the faucet, but I’m pretty new here, and I have a lot of knowledge that I need to understand.

Regards!

Diego.

The faucet is a testnet-only concept. It’s a way to generate new coins for the purpose of testing. Since it requires the key of the minting account, we use a service which holds this key rather than giving everyone this key so they can mint transactions. So to trigger new coins being generated, you need to call this service on testnet. You should be able to follow the same methodology as we use in the code I pointed you towards

I found how to create the GET request to the faucet service in the testnet, but… I can’t follow how to call it, or sign the transaction in my local network.

Following the Client code of the libra client I found that take another flow. It calls mint_coins_with_local_faucet_account in the client_proxy.rs, but I can’t understand how it sign it. Is there a service maybe to retrieve the faucetAccount in my client in order to use it?.
Or how to point to the faucetAccout like the client_proxy does?.
Or maybe is it a grpc service to call to retrieve the fauceAccount with the signature?

Thanks again for your awnsers!

Diego.-

So there are two flows and they follow different patterns.

  1. On testnet, you call the faucet service to mint coins. There is no signing locally. If you want to mint coins, simply make a call to the faucet server in the same manner as mint_coins_with_faucet_service. You cannot locally mint coins on testnet - the only way to mint coins on testnet is via the faucet server.
  2. If you are running a local swarm, there is no faucet server. You instead need to load the faucet file when running the client (the same faucet file that is used by the swarm nodes). You then craft a transaction in the same manner as mint_coins_with_local_faucet_account. This is ONLY used for a local libra swarm and will not work on testnet. When you run the swarm, you’ll see something to the effect of “Faucet account created in file “/var/folders/m5/2kv5_jln12x9bcml9ddmxfnr0000gn/T/keypair.HfizL7dmrfIS/temp_faucet_keys””. That is the keyfile that contains the faucet account. You’ll need to load that in the same way that the client loads it and you’ll then have the local faucet account to use for local minting.