9

Bitcoin has a scripting language built into it, which allows the creation of many kinds of smart contracts. Examples are atomic swaps, Lightning payment channels and zero-knowledge contingent payments (ZKCPs). This later paper by Banasik, Dziembowski and Malinowski (BDM16) improves the efficiency of these greatly. Threshold multisignatures are also easy to ...


7

Note that this question has been automatically mapped to reddit and answered there. If you declare your state variables as public, a function to read their values will be automatically created by the compiler ("accessor function"). If you use the rich interface provided by web3.js, you can create a javascript contract object and just call message() on that ...


6

Yes, Bitcoin could also be subjected to a hardfork. In fact, there are members of the Bitcoin community that feel so strongly that the blocksize should be increased that they are proposing to do just that: They are working on a version of Bitcoin that is incompatible in regard to the current consensus rules of Bitcoin forcing a permanent split of the ...


6

A smart contract can only initiate a transaction when it receives a transaction from either another contract or a user. Thus, all transactions must originate from some user transaction, and it is this transaction that must pay for fees. The amount of fees can be limited by setting the gas limit on that transaction to prevent a malicious contract from ...


5

You can separate concerns - have a contract that the users interface with and that has a reference (an address) of another contract that contains the actual logic. Then, you can control the interface contract and update it with the address of the logic contract on updates.


5

I think it's important to note first that BIP341-BIP342 are improvements to the Bitcoin script "framework" more than they are improvements to the smart contracting "functionality". All Bitcoin scripts can do in practice is enforce combinations of conditions on signatures by certain (sub)sets of signers, timelocks, and revealing hashes. At ...


4

Refer to the documentation: delete myArray[arrayIndex];


4

First off, Lisk doesn't have full turing-complete smart contracts so there isn't much of a comparison on that front. Key shortcomings of existing frameworks like Ethereum can be summarized by five challenges: Contract life cycle management – Find a security bug? Good luck re-deploying. Transaction fees – Want to use my service? First, you’ll have to buy ...


4

The payment channel between Alice and Bob is encoded as a 2-2 multisig Adress the balance of that Adress is the capacity of the channel. A channel is opened by sending funds to that multisig Adress via a funding transaction. These funds do exist (on the Bitcoin network) and are by no means virtual. Alice and Bob each control a key of that Multisig Adress ...


3

there is no such improvement planned for the protocol, only the expected BIP are listed in https://github.com/bitcoin/bips/blob/master/README.mediawiki. but you should understand why in bitcoin only a limited scripting mechanism is used instead a VM with a contract language as for Ethereum (security reasons). the project RSK aims to provide such opportunity ...


3

It is not, sadly. There was a proposal for an ALARM opcode, but it was marked WONTFIX - https://github.com/ethereum/go-ethereum/issues/117 I can see why - timers require that you keep your contract topped up with Ether, and making them too easy to create could litter the blockchain with them and impose an overhead on miners. You either have to have an ...


3

This feature can be easily realised outside the Ethereum virtual machine (and thus keeping the VM simple): Create a (reusable) contract where contracts can register to be called at a certain time (and provide a reward as compensation for the gas costs). A script can poll this contract from outside and call it at the appropriate times. The contract could be ...


3

I would like to explain a bit the smart contract situation in bitcoin, as a "smart contract platform" is not a fixed wording in bitcoin world. As such your question is not clear. Bitcoin already has smart contracts. A good summary was provided by Andrew Poelstra here. When you mention Ethereum, then usually solidity is used, which is "turing complete". ...


3

It's a standard. ALL those ERC20 based tokens have (at least) the same attribute names, the same method names. So I do automaticly know that I need to call the method "transfer" when I want to transfer my tokens. No one would name it "transfer_tokens_hello_world". Irrelevant which of the thousands of token I want to transfer: It's always the same method. ...


3

On ethereum, all tokens are contracts, but not all contracts are tokens. ERC20 is a specific type of contract that is recognized by everyone to be a token contract. It has a base definition and structure that is defined in the ERC20 spec regarding how transfers, balances, approvals, issuance, etc. work. An ICO or anyone issuing a token will write an ERC20 ...


3

Every (full) node in the network verifies all rules. Negative transaction amounts are not valid. If a transaction would contain such a transfer, the transaction would be invalid and ignored by the network. If such a transaction would be contained in a block, nodes would ignore the block, and any block that builds on top, resulting in lost effort for the ...


3

Lots of things called "decentralized" or "defi" are scams, and I vigorously encourage you to stay away from them. Some of them are real, or useful, and have varying degrees of decentralization. Still, nothing is ever going to give you interest if you don't give up custody of your coins. Interest is literally you being paid to take the ...


2

It is not in "the" ethereum spec, so no. But it is a feature that has been discussed for "ethereum 2.0" or similar. It is possible that there may even be a hard fork that will enable it in the then-existing network, but there are none currently planned.


2

No you cannot. A nice way to mimic mutability is via name registration. You can register a name which you distribute to users or use in dapps and other contracts. Whenever you update you update your entry to point to your current contract address.


2

In one word: no. Changing tx output after signing makes existing signature invalid. ( There are some special cases, like signature hash type SIGHASH_SINGLE or SIGHASH_NONE, but we assume that the buyer uses correct signing SIGHASH_ALL )


2

You get a gas refund of 15000 for resetting a storage slot to zero, but you have to use this gas during the current transaction (more specifically, you get at most one half of the total spent gas as a refund). This means you can trade some cleanup with other operations, but you will never be returned such refunded gas in ether. So the general idea is that ...


2

Bitcoin script only allows the conditions under which an output can be spent to be controlled, it does not provide a method for dictating what can happen to the output once these conditions have been satisfied. The concept you are describing is called a coin covenant, the linked thread goes into some detail explaining why this is generally a bad idea.


2

If you want the operation of removing an element from a list to be efficient (i.e. without having to copy the list), you have to use a different data structure, e.g. a linked list or a mapping with a reverse index. Note that delete arr[ind] does not rearrange the array but only resets the array element.


2

Yes. But smart use of smart contacts means you don't need to put all the data on the blockchain. You can keep the actual data offline or only shared between actual participants. Lightning Network is a nice example of such a system. Many other examples can be done using simply multisig and a bit of time locking if necessary. More op-codes and more flexible ...


2

The blockchain does not contain yet-to-be-published transactions to publish them based on conditions. The blockchain is the structure that transactions are published to. There is no such thing as a "pre-loaded transaction" that can be "released". Either A (Alice) or B (Bob) has to publish it. What Alice can do is give Bob a pre-signed transaction that ...


2

Tokens, in general, are not the same as shares in that they do not provide ownership stake or voting rights in the corporation. Typically, they are simply vehicles with which to conduct transactions for the goods or services within the corporate entity from which they are issued. After the ICO where the company sets the price for the tokens, their value is ...


2

If I've understood correctly, I don't think you need block-chain technology to achieve what you want. This is exactly what asymmetric public key encryption is designed for. A simply encrypts some information using A's private key and B's public key... thereby ensuring: Only B can decrypt the information B can verify the information was encrypted by A (...


2

A node that runs a smart contract will be paid with GAS. This is incorrect. The miner who mines the block containing the transaction interacting with a contract is the one who is paid with ETH, which is gas consumed * gas price. How is this node selected? Through the mining process. Or multiple nodes are running the same smart contract just to make ...


2

One idea how to solve it works like this: The sender submits the contract trigger transaction as phased with a reveal secret approval model based on the hash of a secret it generates. The contract activated by this trigger transaction, submits the response transaction(s) with a composite approval model composed of the same hash of the secret used by the ...


2

If Bitcoin has smart contracts, I would like to see how to create a simple "hello world" auction - winner wins, those who didn't win get refunded. Your question isn't clear about the details of how you would expect this to work, so I'll start with some assumptions: The seller has put something up for auction. There are two possibilities: the item being ...


Only top voted, non community-wiki answers of a minimum length are eligible