[(chain - 1)] [(shard - 1)] [ showKeyAction ] This Account is backed by MetaMask. Learn more about  how to use MetaMask for QuarkChain.

Smart Contract on QuarkChain

QuarkChain supports Ethereum smart contracts, therefore you can use your favorite Ethereum tooling like solc and remix to compile the smart contract, deploy here in QuarkChain and interact with them.

It's worth noting that

  1. QuarkChain smart contracts only support in-shard interaction, which means it can only access addresses within the same shard.
  2. Currently, you can only create the contract at the same shard as you

Example

Using following code (source from here, with slight changes) as the example:

pragma solidity ^0.4.24;

contract Greeter {
  address creator;
  string greeting;

  constructor(string _greeting) public {
      creator = msg.sender;
      greeting = _greeting;
  }

  function greet() constant public returns (string) {return greeting; }

  function getBlockNumber() constant public returns (uint) { return block.number; }

  function setGreeting(string _newgreeting) public { greeting = _newgreeting; }
}

Use remix to generate the byte code

0x608060405234801561001057600080fd5b5060405161045938038061045983398101806040528101908080518201929190505050336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508060019080519060200190610089929190610090565b5050610135565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100d157805160ff19168380011785556100ff565b828001600101855582156100ff579182015b828111156100fe5782518255916020019190600101906100e3565b5b50905061010c9190610110565b5090565b61013291905b8082111561012e576000816000905550600101610116565b5090565b90565b610315806101446000396000f300608060405260043610610057576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806342cbb15c1461005c578063a413686214610087578063cfae3217146100f0575b600080fd5b34801561006857600080fd5b50610071610180565b6040518082815260200191505060405180910390f35b34801561009357600080fd5b506100ee600480360381019080803590602001908201803590602001908080601f0160208091040260200160405190810160405280939291908181526020018383808284378201915050505050509192919290505050610188565b005b3480156100fc57600080fd5b506101056101a2565b6040518080602001828103825283818151815260200191508051906020019080838360005b8381101561014557808201518184015260208101905061012a565b50505050905090810190601f1680156101725780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b600043905090565b806001908051906020019061019e929190610244565b5050565b606060018054600181600116156101000203166002900480601f01602080910402602001604051908101604052809291908181526020018280546001816001161561010002031660029004801561023a5780601f1061020f5761010080835404028352916020019161023a565b820191906000526020600020905b81548152906001019060200180831161021d57829003601f168201915b5050505050905090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061028557805160ff19168380011785556102b3565b828001600101855582156102b3579182015b828111156102b2578251825591602001919060010190610297565b5b5090506102c091906102c4565b5090565b6102e691905b808211156102e25760008160009055506001016102ca565b5090565b905600a165627a7a72305820b65144ba1d967908bb1a2d47f6e1c39f81b666ce2776d5ee9791692038a1b0b30029
Then in our devnet, go to Deploy tab, paste the byte code above, set a high gas limit (for example ~3,000,000 to be safe), and click Deploy button.

Once the transaction is confirmed by the network, copy the contract address from the transaction detail page, go to Interact tab, paste the deployed contract's address along with the ABI (which you can also get from remix):
[ placeholder ]
After accessing the contract through the provided ABI, you can read from or write to the contract.

Access
Read / Write Contract

[ method.name ]
Gwei [ selectedMethod.constant ? 'Read' : 'Write' ]
Gwei Deploy
Contract deployment (confirmation time is ~15 seconds)
Update state in the contract

Raw Transaction

[txJson]

Signed Transaction Hash

[txHashSigned()]

From

[ `${fromAddress}` ]
[ `(shard ${fromShard})`.padStart(50) ]

To

[ toShard !== -1 ? `${toAddress}` : "Contract Creation" ]
[ `(shard ${toShard})`.padStart(50) ]

You'll send [ Number(amount) | BN ] [tokenStr]

Max Transaction Fee [ (gasLimit || 1e6) * gasPriceGwei / 1e9 | BN ] [gasTokenStr]

Cancel Submit Transaction