SlideShare a Scribd company logo
6. Use Geth to Access a Deployed
Contract
KC Tam
Reach KC on LinkedIn: https://www.linkedin.com/in/ktam1/
Objective
In this section we deploy the contract using Remix, and use
Geth, a command line tool, to access it.
Geth (Go Ethereum)
Geth is the official Go implementation of Ethereum.
There are three implementations, using Go, Python and C++. Geth is by far the
most common.
A host running Geth becomes part of the Ethereum network (a node).
Besides, Geth also serves as a client and accesses Ethereum node.
● In this section we are using Geth client accessing a contract deployed on
TestRPC.
Ethereum Network (the Giant Computer)
Review: Access
Deployed Contract
Deployed contract can be accessed through
1. Contract Address and
2. Application Binary Interface (ABI)
Deployed Contract
Bytecode
ABI
Contract
Address
Web / Mobile Frontend
Contract AddressABI
Access
TestRPC on Localhost
Deploy the Contract
● Use Remix to deploy the SimpleStorage
contract
● Obtain the Contract Address
● By default, RPC opens on port 8545 on
TestRPC
Deployed Contract
Bytecode
ABI
Contract
Address
http://localhost:8545
First start TestRPC, and in Remix select Web3 Provider to interact with TestRPC.
Use Create to deploy the contract. Note that we see the Contract Address in both Remix and TestRPC.
Obtain ABI from Compile Panel on Remix.
ABI
[{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint
256"}],"payable":false,"stateMutability":"view","type":"function"},
{"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs":
[],"payable":false,"stateMutability":"nonpayable","type":"function"}]
TestRPC on Localhost
Access the Contract
● Run Geth client accessing RPC (port 8545)
● Define an object with ABI and Contract
Address
● Functions are executed through this object.
Deployed Contract
Bytecode
ABI
Contract
Address
geth
Contract AddressABI
Access
object
http://localhost:8545
Use another terminal and access TestRPC using RPC
$ geth attach http://localhost:8545
And we can check the 10 accounts on TestRPC
> eth.accounts
Keep <abi> into a variable abi.
> abi = <abi>
Define an object simpleStorage with abi defined above, and the contract address.
> simpleStorage = eth.contract(abi).at(<copied contract address>)
Now with simpleStorage object we can access variables and functions on this deployed contract.
To get the current value,
> simpleStorage.get()
To set a new value (note: we need to specify an account we use to execute the function.)
> simpleStorage.set(100, {from: eth.account[0]})
Note that this new value can also be seen in Remix
Summary
We use Geth as a console to access a deployed contract on
TestRPC. Both Remix and Geth access the same deployed
contract.

More Related Content

PDF
Use Geth to Deploy Contract
KC Tam
 
PPTX
Design by Contract | Code Contracts in C# .NET
Dariusz Wozniak
 
PPTX
Code Contracts API In .Net
melbournepatterns
 
PPT
Design by contract
Jiří Kiml
 
PPT
computer notes - Data Structures - 18
ecomputernotes
 
PPTX
Generating cross platform .NET based azure IoTdevice
Alon Fliess
 
PDF
OSGi CDI Integration Specification -- Raymond Augé, Liferay
OSGi Alliance
 
ODP
Peaberry - Blending Services And Extensions
Stuart McCulloch
 
Use Geth to Deploy Contract
KC Tam
 
Design by Contract | Code Contracts in C# .NET
Dariusz Wozniak
 
Code Contracts API In .Net
melbournepatterns
 
Design by contract
Jiří Kiml
 
computer notes - Data Structures - 18
ecomputernotes
 
Generating cross platform .NET based azure IoTdevice
Alon Fliess
 
OSGi CDI Integration Specification -- Raymond Augé, Liferay
OSGi Alliance
 
Peaberry - Blending Services And Extensions
Stuart McCulloch
 

Similar to Use Geth to Access a Deployed Contract (20)

PPTX
Blockchain technology-in-fin tech - Anton Sitnikov
DataFest Tbilisi
 
PDF
Programming smart contracts in solidity
Emanuel Mota
 
PDF
First impression of the new cloud native programming language ballerina
Richárd Kovács
 
PDF
HostBridge Blue Prism mainframe automation
HostBridge Technology
 
PDF
Ethereum Smart Contracts on Hyperledger Fabric
Horea Porutiu
 
PDF
Developing applications with Hyperledger Fabric SDK
Horea Porutiu
 
PPTX
Solidity programming Language for beginners
keshabkumar15
 
PDF
Driving containerd operations with gRPC
Docker, Inc.
 
PDF
Making Things Work Together
Subbu Allamaraju
 
PDF
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발
Yunho Maeng
 
PDF
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData
InfluxData
 
PDF
How to Build a Telegraf Plugin by Noah Crowley
InfluxData
 
PPTX
Code contract
Larry Nung
 
PDF
Introduction to Ethereum Smart Contracts
ArcBlock
 
KEY
Google io bootcamp_2010
Chris Ramsdale
 
PDF
Web Authentication API
FIDO Alliance
 
PDF
Algorand Smart Contracts
ssusercc3bf81
 
PDF
Maximize the power of OSGi in AEM
ICF CIRCUIT
 
PPTX
Workshop: .NET Code Contracts
Rainer Stropek
 
PDF
Joe Walker Interactivewebsites Cometand Dwr
deimos
 
Blockchain technology-in-fin tech - Anton Sitnikov
DataFest Tbilisi
 
Programming smart contracts in solidity
Emanuel Mota
 
First impression of the new cloud native programming language ballerina
Richárd Kovács
 
HostBridge Blue Prism mainframe automation
HostBridge Technology
 
Ethereum Smart Contracts on Hyperledger Fabric
Horea Porutiu
 
Developing applications with Hyperledger Fabric SDK
Horea Porutiu
 
Solidity programming Language for beginners
keshabkumar15
 
Driving containerd operations with gRPC
Docker, Inc.
 
Making Things Work Together
Subbu Allamaraju
 
[Call for code] IBM 블록체인을 활용하여 투명하게 구호기금 관리하기 - Hyperledger Fabric v1.1 by 맹개발
Yunho Maeng
 
Building a Telegraf Plugin by Noah Crowly | Developer Advocate | InfluxData
InfluxData
 
How to Build a Telegraf Plugin by Noah Crowley
InfluxData
 
Code contract
Larry Nung
 
Introduction to Ethereum Smart Contracts
ArcBlock
 
Google io bootcamp_2010
Chris Ramsdale
 
Web Authentication API
FIDO Alliance
 
Algorand Smart Contracts
ssusercc3bf81
 
Maximize the power of OSGi in AEM
ICF CIRCUIT
 
Workshop: .NET Code Contracts
Rainer Stropek
 
Joe Walker Interactivewebsites Cometand Dwr
deimos
 
Ad

More from KC Tam (9)

PDF
Access Tokens from Metamask
KC Tam
 
PDF
Implement ERC20 on TestRPC
KC Tam
 
PDF
ERC20 Token Contract
KC Tam
 
PDF
Ethereum: Native Currency and Token
KC Tam
 
PDF
Use TestRPC in Remix
KC Tam
 
PDF
Contract Practice with Remix
KC Tam
 
PDF
Solidity Contract: the code, compilation, deployment and accessing
KC Tam
 
PDF
Access a Simple DApp
KC Tam
 
PDF
Essential Ethereum
KC Tam
 
Access Tokens from Metamask
KC Tam
 
Implement ERC20 on TestRPC
KC Tam
 
ERC20 Token Contract
KC Tam
 
Ethereum: Native Currency and Token
KC Tam
 
Use TestRPC in Remix
KC Tam
 
Contract Practice with Remix
KC Tam
 
Solidity Contract: the code, compilation, deployment and accessing
KC Tam
 
Access a Simple DApp
KC Tam
 
Essential Ethereum
KC Tam
 
Ad

Recently uploaded (20)

PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
PDF
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PDF
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Software Development Methodologies in 2025
KodekX
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Get More from Fiori Automation - What’s New, What Works, and What’s Next.pdf
Precisely
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Using Anchore and DefectDojo to Stand Up Your DevSecOps Function
Anchore
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Event Presentation Google Cloud Next Extended 2025
minhtrietgect
 
MASTERDECK GRAPHSUMMIT SYDNEY (Public).pdf
Neo4j
 
The Future of Artificial Intelligence (AI)
Mukul
 
Security features in Dell, HP, and Lenovo PC systems: A research-based compar...
Principled Technologies
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Software Development Methodologies in 2025
KodekX
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 

Use Geth to Access a Deployed Contract

  • 1. 6. Use Geth to Access a Deployed Contract KC Tam Reach KC on LinkedIn: https://www.linkedin.com/in/ktam1/
  • 2. Objective In this section we deploy the contract using Remix, and use Geth, a command line tool, to access it.
  • 3. Geth (Go Ethereum) Geth is the official Go implementation of Ethereum. There are three implementations, using Go, Python and C++. Geth is by far the most common. A host running Geth becomes part of the Ethereum network (a node). Besides, Geth also serves as a client and accesses Ethereum node. ● In this section we are using Geth client accessing a contract deployed on TestRPC.
  • 4. Ethereum Network (the Giant Computer) Review: Access Deployed Contract Deployed contract can be accessed through 1. Contract Address and 2. Application Binary Interface (ABI) Deployed Contract Bytecode ABI Contract Address Web / Mobile Frontend Contract AddressABI Access
  • 5. TestRPC on Localhost Deploy the Contract ● Use Remix to deploy the SimpleStorage contract ● Obtain the Contract Address ● By default, RPC opens on port 8545 on TestRPC Deployed Contract Bytecode ABI Contract Address http://localhost:8545
  • 6. First start TestRPC, and in Remix select Web3 Provider to interact with TestRPC.
  • 7. Use Create to deploy the contract. Note that we see the Contract Address in both Remix and TestRPC.
  • 8. Obtain ABI from Compile Panel on Remix. ABI [{"constant":true,"inputs":[],"name":"get","outputs":[{"name":"retVal","type":"uint 256"}],"payable":false,"stateMutability":"view","type":"function"}, {"constant":false,"inputs":[{"name":"x","type":"uint256"}],"name":"set","outputs": [],"payable":false,"stateMutability":"nonpayable","type":"function"}]
  • 9. TestRPC on Localhost Access the Contract ● Run Geth client accessing RPC (port 8545) ● Define an object with ABI and Contract Address ● Functions are executed through this object. Deployed Contract Bytecode ABI Contract Address geth Contract AddressABI Access object http://localhost:8545
  • 10. Use another terminal and access TestRPC using RPC $ geth attach http://localhost:8545 And we can check the 10 accounts on TestRPC > eth.accounts
  • 11. Keep <abi> into a variable abi. > abi = <abi>
  • 12. Define an object simpleStorage with abi defined above, and the contract address. > simpleStorage = eth.contract(abi).at(<copied contract address>) Now with simpleStorage object we can access variables and functions on this deployed contract.
  • 13. To get the current value, > simpleStorage.get() To set a new value (note: we need to specify an account we use to execute the function.) > simpleStorage.set(100, {from: eth.account[0]}) Note that this new value can also be seen in Remix
  • 14. Summary We use Geth as a console to access a deployed contract on TestRPC. Both Remix and Geth access the same deployed contract.