FAQ - Developers
This section covers frequently asked questions and our recommendations from the developer's perspective.
How do I fix a linking error with 'cargo build' on Windows?
Question : How can I fix this linking error while running
cargo build on Windows?
Answer : You have to install the VC+ build tools so that
rustc can auto-detect the helper files that are part of the building process. Or you can build using Visual Studio 2013 or 2015. There are two existing Rust toolchain families provided for Windows:
msvc is the default, and as you realized, it depends on a recent Visual C++ installation.
gnu, on the other hand, depends on GNU/MinGW-w64. It can be installed and made the default toolchain using this command:
$ rustup default stable-x86_64-pc-windows-gnu
Why do I get an invalid toolchain name?
Question : How can I fix an error caused by an invalid toolchain name, such as:
error: caused by: invalid toolchain name:...?
Answer : First, check your
rustup version using the following commands:
Then, find the appropriate remedy:
- Set the minimal rustup profile:
rustup set profile minimal
- Install the nightly Rust toolchain separately with these two commands:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain none -y
rustup toolchain install nightly --allow-downgrade --profile minimal --component clippy
- Update rustup with one of these commands:
rustup self update
Refer to the Rust toolchain installer for more details.
What should I do if I am encountering errors installing cargo-casper?
Ensure that you have installed both Rust and CMake before attempting to install cargo-casper.
What are missing generic arguments in 'cargo build'?
Question : The
cargo build --release command fails due to missing generic arguments. How can I fix this?
Answer : This is a library compatibility issue that occurs with CMake version 18.04. Use
cmake --version to check your current version of CMake. If you are on this version, perform an upgrade:
sudo snap install cmake
Can blockchain smart contracts interact with the outside world?
No, smart contracts cannot interact with the world outside of the blockchain on which they live. For example, a smart contract cannot act as a REST endpoint or data source. Smart contracts can interact with other contracts in the same environment, or with compatible external libraries. When creating an external library to interact with a Casper smart contract, consider the following:
- Wasm is expressed as
little-endianby default. Check for endianness compatibility.
wasm32-unknown-unknownis a 32-bit platform, it cannot support 64-bit external code. Your library needs to be compatible with 32-bit code.
- Consider a library that supports
- Try to avoid native operating system calls. If the library uses the filesystem, sockets, or other native OS functionality, then it may not work with a Casper smart contract.
Why do I receive a 'casper-client: command not found' error?
Refer to the Casper Command-line Client document for instructions on interacting with a Casper network.
What determines the cost of a deploy?
Native system transfers have a fixed gas cost. Calling system contracts by their hashes also has a fixed cost.
If two calls with different arguments but for the same hash show different gas costs, it is a result of executed Wasm code. Different arguments may lead to different code paths and executed opcodes. You cannot predict the number of executed opcodes or host functions.
If the calls use the same arguments, yet the cost is increasing, you might consider reviewing your global state usage. There is a chance that you are reading a collection from the global state, updating it and writing back with a larger size.
Why does my deploy get an 'Out of Gas' error?
If you received this error, the specified payment amount for the deploy was insufficient. Try specifying a higher amount of CSPR and re-send the deploy. See the note about gas price within Sending Deploys to the Network.
How do I know that a deploy was finalized?
Is there a client API to query a Casper node's RPC endpoint?
You can query the JSON-RPC API of a node on a Casper network. You will need the IP address of a node and the REST endpoint for status and metrics, which is by default 8888 on Mainnet and Testnet. You can find specific node addresses for Testnet or Mainnet.
You can also run the Casper client
list-rpcs command to get the full list of available JSON-RPC methods. You will need the RPC endpoint for interaction with the casper-client, which is by default 7777 on Mainnet and Testnet.
casper-client list-rpcs --node-address <HOST:7777>
How can I monitor the events a node is emitting?
You can monitor a node's event stream on the port specified as the
event_stream_server.address in the node's configuration (config.toml), which is by default 9999 on Testnet and Mainnet. You will need the IP address of a peer on the network. For details and examples, visit the Monitoring Events page.
How can I query a deploy for an account?
On-chain accounts are associated with an account public key. Deploy data includes the account's public key as a sub-field.
When are finality signatures needed?
Suppose an exchange connects to someone else's node RPC to send deploys to the network. In this case, the node is considered high risk, and the exchange must assert finality by checking to see how many validators have run the deploys in the network.
How is a deploy_hash different than a transfer_hash?
Does the node API have a 'getTransactions' function?
The Casper node provides a
chain_get_block_transfers JSON-RPC method, which returns all transfers for a block from the network. Run the Casper client
list-rpcs command to get the full details of the RPC API. You will need the IP address of a node and the RPC endpoint for interaction with the casper-client, which is by default 7777 on Mainnet and Testnet.
casper-client list-rpcs --node-address <HOST:7777>
The Casper client also provides the
get-block-transfers subcommand, which uses
chain_get_block_transfers under the hood. To find out more about
get-block-transfers, run the help command:
casper-client get-block-transfers --help
When is the balance updated after a deploy?
Execution occurs after consensus. As outlined in the dApp Developer Guide, deploys are queued in the system before being listed in a block for execution.
Balance updates should occur after contract execution and block finalization.
How do I handle a deploy composed of multiple transfers?
Applying a unique ID to each transfer can mitigate issues with multiple transfers in a single deploy. Once included in a block, the network finalizes the deploy containing multiple transfers.
Operating with Keys
How should we work with the PEM keys?
What is the difference between key management and deploys?
There are two types of action that an account can perform: a deploy and key management. Deploys are simply executing some code on the blockchain, while key management involves changing the associated keys. Key management cannot occur independently but must come via a deploy. Therefore, a key management action implies that a deploy action also occurs.
You may also reference the following two documents for additional information:
Is there a way to query all the '(key, value)' pairs in a 'casper dictionary'?
No, you need to know the keys beforehand. If you want to iterate over the dictionary list, you can list keys numerically and keep the length in another value.
Information on nctl
Some nctl commands are working correctly, while others are causing errors.
This issue may be caused by an incomplete or unsuccessful install of nctl. Once it is installed, use the command
nctl-status to see if it is running normally. It should show five running noes and five stopped.
If it does not, the nctl install did not install correctly. Usually, the failure reasons are OS and hardware specifications. If you are running Linus on Windows, we suggest switching to VirtualBox.
How do I fix an openssl error when compiling nctl?
Question : When I attempted to run 'nctl-compile' on MacOS, I received the following error: 'error: failed to run custom build command for openssl-sys v0.9.67'. How can I fix this?
Answer : If you issue the command
brew info openssl it will return info that appears similar to the following:
For pkg-config to find openssl@3 you may need to set:
The next step is to issue the above command. In this example, you would use
nctl-compile should work correctly.
How do I fix connection errors with nctl?
Question : When running nctl, how do I resolve a
Failed to get RPC response: error sending request for url (http://127.0.0.1:22102/rpc): connection error: Connection reset by peer (os error 54) error?
Answer : You should specify RPC ports as follows:
address = "0.0.0.0:11102"
You can find more command info here.
What factors cause the 'APIError::InvalidPurse' error?
The three main factors that cause an InvalidPurse error are:
- The purse in question does not exist.
- The purse is not of type U512.
- The sending and receiving purses are identical.
What causes an 'ApiError::MissingArgument ' error?
This error occurs when there is an incorrect session argument. The session argument must be U512.
Why do I get an 'Encountered operation forbidden by gas rules' error?
Casper node does not natively allow floating point opcodes.
How do I add ZK proofs within Casper?
ZK proof inclusion would require building the proof verification inside the smart contract. You would need to add either of the following to your contract:
- GitHub - paritytech/bn: Pairing cryptography library in Rust
- GitHub - zkcrypto/pairing: Pairing-friendly elliptic curve library.
Verifications would then need to use the associated library.