'VM execution error at contract simulation UMA LSP contract

I am trying to deploy a smart contract on Kovan testnet with the UMA protocol. More specifically following this tutorial: https://docs.umaproject.org/developers/deploy-an-lsp

I am running the deployment script with the following parameters:

node index.js 
--gasprice 15 
--url wss://kovan.infura.io/ws/v3/PROJECTIDInfura
--mnemonic "SEED PHRASE"
--pairName "WHTUSDJune" 
--expirationTimestamp 1655312460 
--collateralPerPair 1000000000 
--priceIdentifier BTCUSD 
--longSynthName "wheat_SRW_June_long" 
--longSynthSymbol WHTUSDBJun 
--shortSynthName "wheat_SRW_June_short" 
--shortSynthSymbol WHTUSDSJun 
--collateralToken 0x7079f3762805cff9c979a5bdc6f5648bcfee76c8 
--fpl Linear 
--lowerBound 0 
--upperBound 2000000000 
--proposerReward 2000000 
--optimisticOracleProposerBond 200000000 

But this is the error I get at contract simulation:

Error: VM execution error.
    at WebsocketSubprovider._handleSocketMessage (C:\Users\FOLDER\launch-lsp\node_modules\@trufflesuite\web3-provider-engine\subproviders\websocket.js:121:18)
    at WebSocket.onMessage (C:\Users\FOLDER\launch-lsp\node_modules\ws\lib\event-target.js:120:16)
    at WebSocket.emit (events.js:315:20)
    at Receiver.receiverOnMessage (C:\Users\FOLDER\launch-lsp\node_modules\ws\lib\websocket.js:720:20)
    at Receiver.emit (events.js:315:20)
    at Receiver.dataMessage (C:\Users\FOLDER\launch-lsp\node_modules\ws\lib\receiver.js:414:14)
    at C:\Users\FOLDER\launch-lsp\node_modules\ws\lib\receiver.js:371:23
    at C:\Users\FOLDER\launch-lsp\node_modules\ws\lib\permessage-deflate.js:307:9
    at C:\Users\FOLDER\launch-lsp\node_modules\ws\lib\permessage-deflate.js:389:7
    at afterWrite (_stream_writable.js:468:5)
    at onwrite (_stream_writable.js:448:7)
    at InflateRaw.afterTransform (_stream_transform.js:98:3)
    at Zlib.processCallback (zlib.js:580:8) 

What I am doing wrong?



Solution 1:[1]

Found out which parameter was making my request crash. It is:

--priceIdentifier BTCUSD 

I replaced it with

--priceIdentifier UMAUSD

and it worked like a charm. Not sure why as BTCUSD is listed as a price identfier on their site.

Solution 2:[2]

I could not compile your code, so I made some changes

static void Main()
{
    var name = string.Empty;
    var choice = string.Empty;
    do 
    {
        Console.WriteLine("Enter your name");
        name = Console.ReadLine();
        name = name?.ToLower();
        if (name != null && name.Length>1)
                name = char.ToUpper(name[0]) + name.Substring(1);
        
        Console.WriteLine("");
        Console.WriteLine("Your name is " + name + ", is that correct?");
        Console.WriteLine("");
        Console.WriteLine("1: Yes");
        Console.WriteLine("2: No");
        choice = Console.ReadLine();
        if (choice == "1") break;
        
        if (choice == "2")Console.WriteLine("");
        else Console.WriteLine("Invalid Claim");
    
        } while (true);
        
    Console.WriteLine(name);
}

Solution 3:[3]

Why use a nullable string in this software?

You didn't initialize the name at the beginning, if your loop will never run, then the name output line will be NULL. This is what your error points to.

It is better to initialize variables before their first use, as they can be NULL by default (valid for reference types such as classes). For a string, one option would be String.Empty

string name = String.Empty, choice = String.Empty;

These two lines can be combined:

 bool finishnameingcharacter;
 finishnamingcharacter = true;

 // Replaced by
 bool finishnameingcharacter = true;

On the next line in the while loop, you check the condition: finishingnamingcharacter == false. The loop checks the condition and only then executes. To execute the loop, you need the condition to be TRUE, but it will not take this value, because earlier you defined the variable finishnamingcharacter = true. true != false. By default you need to define this variable as false

bool finishnameingcharacter = false;

The user can enter an empty string value, so converting it to lowercase immediately doesn't matter, as long as it checks for an empty string. There is a special method for checking if a string is empty: string.IsNullOrEmpty() - it returns true if the string is empty or null. If the user entered the wrong name, then we need to ask him to enter again, for this, the continue operator is used.

name = Console.ReadLine();
if(string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
{
    Console.WriteLine("Sorry, your name is empty. Please enter again.")
    continue;
}
//So if name is not empty: jOhN
name = name.ToLower(); //john
name = char.ToUpper(name[0]) + name.Substring(1); //John

For boolean values it is better to use reserved words, i.e. instead of finishnamingcharacter = 1 it is better to write finishnamingcharacter = true

Rest of the code looks good. We all took the first steps :)

Full modified code here:

class Program
{
    static void Main()
    {
        string name = String.Empty choice = String.Empty;
        bool finishnameingcharacter = false;

        while(finishingnamingcharacter == false)
        {
            Console.WriteLine("Enter your name");
            name = Console.ReadLine();
            if(string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
            {
                Console.WriteLine("Sorry, your name is empty. Please enter again.")
                continue;
            }
            //So if name is not empty: jOhN
            name = name.ToLower(); //john
            name = char.ToUpper(name[0]) + name.Substring(1); //John

            Console.WriteLine("");
            Console.WriteLine("Your name is " +name+ ", is that correct?");
            Console.WriteLine("");
            Console.WriteLine("1: Yes");
            Console.WriteLine("2: No");
            choice = Console.ReadLine();

            if(choice == "1")
            {
                finishnamingcharacter = true;
            }
            else if(choice == "2")
            {
                Console.WriteLine("");
            }
            else
            {
                Console.WriteLine("Invalid Claim")
            }
        }

        Console.WriteLine(name);
    }
}

PS There is a special method TextInfo.ToTitleCase() "wAr aNd pEaCe to titlecase: War And Peace" - I advise you to read

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dimitri
Solution 2 Serge
Solution 3 On_Luck