A smart contract is superior to a trusted third party because of a number of reasons e.g.
#Rust convert mac address to u8 code
The blockchain way is to replace the trusted third party C with code on a blockchain, specifically a smart contract that verifiably acts the same way a trusted third party would. C then waits for the other party to send their asset and only then does C release both assets. A or B can now go first and send their asset to C. The traditional way to solve this problem is to introduce a third party C which both A and B trust. After all, what if the other party does not hold up their end of the trade and runs away with both assets? A deadlock will be reached where no party wants to send their asset first. They would like to trade their assets but neither wants to send their asset first. Imagine Alice has an asset A and Bob has an asset B.
For those unfamiliar with the concept, here is a brief explainer. # What is an escrow?Īn escrow smart contract is a good example to look at and build because it highlights well what a blockchain makes possible while still being easy to understand, allowing us to focus on the code itself. # The Final Productīefore we start coding, let's look at the final product to understand what we are building: an escrow program. If you find mistakes or would like to give feedback, please do contact me on discord paulx#9059 (opens new window) or twitter (opens new window). If something is not working and you just cannot figure out why, have a look at the final code here (opens new window). If you're new to Solana and Rust and want to finish this post without breaks and leave with a solid understanding of all concepts discussed and links mentioned I recommend allocating an entire day to the post. I do not claim to explain all topics but hope this will be a solid starting point from which the reader can explore Solana further.
Let code = "os.getenv('USER') or os.getenv('USERNAME') or 'Unknown'"
We can't display Python exceptions via std::fmt::Display, // so print the error here manually.