Skip to content

Commit

Permalink
Basic string support.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariaKt committed Nov 6, 2024
1 parent 50696ea commit 556a2f9
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
64 changes: 64 additions & 0 deletions byol_solidity.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
'maxPriorityFeePerGas': 1000000000,
}

# deploy USDC
print("Deploying USDC...")

tx_hash = w3.eth.send_transaction(deploy_usdc_tx)
print(tx_hash)
receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
Expand All @@ -44,10 +47,14 @@
'maxPriorityFeePerGas': 1000000000,
}

# mint USDC
print("Minting USDC...")

tx_hash = w3.eth.send_transaction(mint_usdc_tx)
print(tx_hash)
receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
print(receipt)
print("USDC Address:", usdc_address)

balanceOf_usdc_data = '70a08231000000000000000000000000' + sender.address[2:]

Expand All @@ -61,6 +68,9 @@
'maxPriorityFeePerGas': 1000000000,
}

# balanceOf USDC
print("balanceOf USDC...")

balance = w3.eth.call(balanceOf_usdc_tx)
print(balance)

Expand All @@ -76,11 +86,17 @@
'maxPriorityFeePerGas': 1000000000,
}

# transfer USDC
print("transfer USDC...")

tx_hash = w3.eth.send_transaction(transfer_usdc_tx)
print(tx_hash)
receipt = w3.eth.wait_for_transaction_receipt(tx_hash)
print(receipt)

# balanceOf USDC
print("balanceOf USDC...")

balance = w3.eth.call(balanceOf_usdc_tx)
print(balance)

Expand All @@ -89,3 +105,51 @@

balance = w3.eth.call(balanceOf_usdc_tx)
print(balance)

# decimals USDC
decimals_usdc_data = '313ce567'
decimals_usdc_tx = {
'from': sender.address,
'data': decimals_usdc_data,
'to': usdc_address,
'value': 0,
'gas': 11000000,
'maxFeePerGas': 2000000000,
'maxPriorityFeePerGas': 1000000000,
}

decimals = w3.eth.call(decimals_usdc_tx)
print("Decimals:", int(decimals.hex(), 16))

# name
name_usdc_data = '06fdde03'
name_usdc_tx = {
'from': sender.address,
'data': name_usdc_data,
'to': usdc_address,
'value': 0,
'gas': 11000000,
'maxFeePerGas': 2000000000,
'maxPriorityFeePerGas': 1000000000,
}

name = w3.eth.call(name_usdc_tx)
name = w3.to_text(name)
print("Name:", name)

# symbol
symbol_usdc_data = '95d89b41'
symbol_usdc_tx = {
'from': sender.address,
'data': symbol_usdc_data,
'to': usdc_address,
'value': 0,
'gas': 11000000,
'maxFeePerGas': 2000000000,
'maxPriorityFeePerGas': 1000000000,
}

symbol = w3.eth.call(symbol_usdc_tx)
symbol = w3.to_text(symbol)
print("Symbol:", symbol)

3 changes: 3 additions & 0 deletions src/solidity.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ module SOLIDITY-ULM-SIGNATURE-IMPLEMENTATION
rule getOutput(<generatedTop>...
<k> v(false, bool) ...</k>
...</generatedTop>) => Int2Bytes(32, 0, BE)
rule getOutput(<generatedTop>...
<k> S:String ...</k>
...</generatedTop>) => Int2Bytes(32, 32, BE) +Bytes Int2Bytes(32, lengthString(S), BE) +Bytes padRightBytes(String2Bytes(S), 32, 0) // TODO: All strings in the EVM ABI must be UTF-8 encoded to bytes
// getGasLeft returns the amount of gas left by reading it from the cell <gas>.
// The semantics currently initialize the gas by reading the appropriate ULM
Expand Down
8 changes: 8 additions & 0 deletions test/demo-contracts/USDCMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ contract USDCMock {
return dec;
}

string name() {
return "USD Coin";
}

string symbol() {
return "USDC";
}

function mint(address account, uint256 value) public {
require(account != address(0), "USDC: invalid receiver");
_update(address(0), account, value);
Expand Down

0 comments on commit 556a2f9

Please sign in to comment.